1

For some webserver testing, I use curl for file upload like this:

$ curl --silent --digest --user user:pass --upload-file filename http://server/dir/

Now I tried to archive the same function but with usage of httpie. Tried something like:

$ http --auth-type digest --auth user:pass PUT http://server/dir/

but cannot find a parameter to pass a filename for upload. Trying e.g. this

$ http --auth-type digest --auth user:pass PUT http://server/dir/ A=B

has the consequence that the content {"A": "B"} will be passed as http request body, but I want to pass the raw content of a (maybe binary) file as request body instead (like possible with curl).

Might there be a way to do this also using httpie?

(I'd tested with httpie 0.9.2 on Kubuntu 16.04 host.)

0

Ok, digging deeper into httpie documentation, finding out that there are 2 ways to pass raw body data.

Either by piping or input redirection. httpie reads the body data from stdin:

$ cat filename | http --auth-type digest --auth user:pass PUT http://server/dir/filename

or

$ http --auth-type digest --auth user:pass PUT http://server/dir/filename <filename

or using that @ parameter like this:

$ http --auth-type digest --auth user:pass PUT http://server/dir/filename @filename

See also:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.