cli
cli copied to clipboard
Bad filename when having non ASCII characters
Checklist
- [x] I've searched for similar issues.
- [x] I'm using the latest version of HTTPie.
Minimal reproduction code and steps
- save a dummy image as
天狗.png
- issue a multipart/form-data, such as:
https --offline --multipart https://example.org name='John Doe' file_field@/home/john/天狗.png
> /tmp/httpie_result.txt
Current result
The Content-Disposition
header generated will be something like: Content-Disposition: form-data; name="file_field"; filename="天狗.png"
…
Expected result
The Content-Disposition
header should conform to rfc2231. So this should rather be: Content-Disposition: form-data; name="file_field"; filename*=UTF-8''%E5%A4%A9%E7%8B%97.png
You can generate the proper encoded filename in accordance with rfc2231 using the perl command line perl -MEncode -MURI::Escape::XS -lE 'say URI::Escape::XS::uri_escape( Encode::decode_utf8("天狗.png") )'
…
Debug output
Please re-run the command with --debug
, then copy the entire command & output and paste both below:
$ http --debug <COMPLETE ARGUMENT LIST THAT TRIGGERS THE ERROR>
<COMPLETE OUTPUT>
Additional information, screenshots, or code examples
…
Thanks @jackdeguest, we will be looking for this one!
This is problem for downloaded content as well
@isidentical any progress here? 🙏
It's fixed in PR https://github.com/httpie/cli/pull/1531
If you want to try it out: pip install "git+https://github.com/Ousret/HTTPie.git@feature-tryout-niquests" -U