ducaale/xh

HTTPie feature parity checklist

ducaale opened this issue · 7 comments

  • Support =@ and :=@ as seperators in request data.
  • Support ==@ and :@ for reading query string and header values from a file (#288)
  • Support specifying file type in multipart requests i.e key@file_name;type=file_type.
  • Support --response-charset and --response-mime flags. (#184)
  • Support custom boundary in multipart requests (currently not supported in reqwest).
  • Support unsetting headers + empty headers.
  • Support reading request body from stdin.
  • Support --raw flag (#202)
  • Support reading request data from a file.
  • Support piping response body to stdout (including binary).
  • Support unbuffered streamed responses.
  • Support Download mode.
  • Support resuming interrupted downloads
  • Support Sessions. (#125)
  • Support HEAD HTTP method.
  • Support --all flag for printing intermediary requests/responses. (#137)
  • Support --history-print. (#137)
  • Support the --timeout flag.
  • Support default options (#165)
  • Support the --path-as-is flag
  • Decode responses compressed in deflate format. (#158)
  • Support --compress flag.
  • Support --chunked flag.
  • Support -vv/--meta flags. (#240)
  • Add Monokai theme. (#157)
  • Add Fruity theme. (#206)
  • Support Digest authentication. (#176)
  • (undecided) Warn the user when there is no incoming data after a certain time passed on stdin.
abner commented

httpie uses the value of environment variable REQUESTS_CA_BUNDLE to verify if it is present.
Would be nice if xh uses it too.

It doesn't seem to be mentioned in the docs but it is, in fact, something that HTTPie supports.

The library we use for parsing command-line arguments supports falling back to an env variable so this should be an easy one to implement. Would like to create a PR for it?

Edit: this has been implemented in #146

requests checks both REQUESTS_CA_BUNDLE and CURL_CA_BUNDLE, so perhaps we should also look for both.

So this means we can no longer use the nice API that structopt offers. If that is the case, we should manually check for those env variables inside the from_iter_safe() function and then set cli.verify from there.

xh does not process query parameter read from file as httpie does:

Prepare a file with value for query parameter

First we create a file with a value to use:

$ echo "filed-value" > arg.value

Use http, reading query parameter from the file

Then using http we ask to use this value read from the file for query parameter arg:

$ http https://httpbin.org/get arg==@arg.value
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Connection: keep-alive
Content-Length: 342
Content-Type: application/json
Date: Wed, 05 Oct 2022 23:11:13 GMT
Server: gunicorn/19.9.0

{
    "args": {
        "arg": "filed-value"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate",
        "Host": "httpbin.org",
        "User-Agent": "HTTPie/3.2.1",
        "X-Amzn-Trace-Id": "Root=1-633e0f11-6265bd27088a85585daa3a5d"
    },
    "origin": "185.151.252.82",
    "url": "https://httpbin.org/get?arg=filed-value"
}

As we can see, the response report the value for arg is "filed-value" as expected.

Use xh to read the query parameter from the file - fails with using the file name

Now try the same with xh:

$ xh https://httpbin.org/get arg==@arg.value
HTTP/2.0 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
content-length: 343
content-type: application/json
date: Wed, 05 Oct 2022 23:11:31 GMT
server: gunicorn/19.9.0

{
    "args": {
        "arg": "@arg.value"
    },
    "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip, deflate, br",
        "Host": "httpbin.org",
        "User-Agent": "xh/0.16.1",
        "X-Amzn-Trace-Id": "Root=1-633e0f23-1fbbb3d05048db3a7649a622"
    },
    "origin": "185.151.252.82",
    "url": "https://httpbin.org/get?arg=%40arg.value"
}

As can be seen, it did not read the value from the file, instead it used value of the file itself.

Thanks, @vlcinsky. I have now included this in the feature compatibility checklist.

For reference, httpie/cli#1225 is the PR that added support for reading header and query string values from a file.

@ducaale great.

Just a note: http does urlencoding for the values read from the file before putting it into final url string.