Open ducaale opened 3 years ago
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 https://github.com/ducaale/xh/pull/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:
First we create a file with a value to use:
$ echo "filed-value" > arg.value
http
, reading query parameter from the fileThen 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.
xh
to read the query parameter from the file - fails with using the file nameNow 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, https://github.com/httpie/httpie/pull/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.
=@
and:=@
as seperators in request data.==@
and:@
for reading query string and header values from a file (#288)key@file_name;type=file_type
.--response-charset
and--response-mime
flags. (#184)--raw
flag (#202)HEAD
HTTP method.--all
flag for printing intermediary requests/responses. (#137)--history-print
. (#137)--timeout
flag.--path-as-is
flag--compress
flag.--chunked
flag.-vv
/--meta
flags. (#240)