curlify icon indicating copy to clipboard operation
curlify copied to clipboard

does not handle Binary files

Open Nicolas-Masson-Wizaplace opened this issue 6 years ago • 7 comments

I made a fix to make it works with posting CSV files, but have no success with Jpeg file.

Ok, I'll look into it

ofw avatar Jul 21 '19 09:07 ofw

2 PR that would fix this :) https://github.com/ofw/curlify/pull/22 https://github.com/ofw/curlify/pull/23

leNEKO avatar Dec 11 '19 22:12 leNEKO

@leNEKO @ofw is it possible to merge this PRs?

ornichola avatar Jan 29 '21 17:01 ornichola

I have the same issue.

Body: n'x\x9c\x95Skk\xe2@\x...

Error:

File "/opt/ls/lx/release/d_dwe_lxstacon/local/ux_app/python/lib/python3.6/site-packages/curlify.py", line 28, in to_curl
    body = body.decode('utf-8')

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9c in position 1: invalid start byte

DennyWeinberg avatar Aug 09 '21 09:08 DennyWeinberg

curlify always attempts to decode bytes into utf-8, which is almost always incorrect as different Content-Types are being used. In my case I solved it here by ensuring that the Content-Type is what I expect, then removing it from the request and decoding the bytes appropriately before passing the object to curlify.

I think that if curlify gets a request with non-textual Content-Type (or rather, if it gets body which is bytes) then it should prepare a command like echo -e .... | curl --data-binary @- as described here.

Jongy avatar May 20 '22 15:05 Jongy