Httpie: Mechanism to pass custom headers before URL

Created on 19 Jul 2016  ·  3Comments  ·  Source: httpie/httpie

The input format for custom headers (http URL customer-header customer-header...) is very strange compared to cURL. cURL offers -H for custom headers. This makes it easy to define presets (like bash aliases) that include headers. I'm not a bash expert, but there doesn't seem to be an easy way to do that with http.

Most helpful comment

Having custom headers before url also allows you to edit url easily from bash history. You don't have to move left to url to edit the url endpoint.

All 3 comments

This should work (in bash):

function myhttp {
    http "$@" 'Foobar:asdf'
}

The order in which the REQUEST_ITEMs are specified doesn't matter. Although I have to admit that I didn't hit on this immediately and wrote a fancy script that mangled the METHOD/URL parameters :smile:

Perhaps this would be worth documenting somewhere (in case it isn't already).

Having custom headers before url also allows you to edit url easily from bash history. You don't have to move left to url to edit the url endpoint.

Also dropping by to voice support for this feature.

Was this page helpful?
0 / 5 - 0 ratings