tatsuhiro-t / spdylay

The experimental SPDY protocol version 2, 3 and 3.1 implementation in C
http://tatsuhiro-t.github.io/spdylay/
MIT License
602 stars 102 forks source link

Uploading file with spdycat #127

Closed jarmo closed 9 years ago

jarmo commented 9 years ago

I'm trying to upload a file using multipart request, but not able to do that with spdycat.

Here's how i'm uploading file with curl: curl -X POST -F "file=@my-file" https://example.com/upload

This is how i tried it with spdycat: spdycat --data my-file https://example.com/upload

It does not seem to work as nginx with spdy module returns with http 400 and in logs i can see that Content-Type header is missing.

What am i doing wrong and how to achieve file upload similar to curl?

tatsuhiro-t commented 9 years ago

spdycat does not support multipart uploading at the moment. It just upload the content of the given file. The workaround is create multipart data in advance in a file and upload it with -d option.

jarmo commented 9 years ago

Thanks! This works.

However, i cannot seem to use stdin as a file like this: gzip -c foo.bar | ./spdycat --data - https://server.com

It does send something with content-length of 0 if use - as an input.

tatsuhiro-t commented 9 years ago

This is a bug. --data - works with file only. We have a similar fix for nghttp client (https://github.com/tatsuhiro-t/nghttp2/commit/a8a66843db98377398edf6f65d3dabe35e82b98f) and can port here.

tatsuhiro-t commented 9 years ago

Fix committed via 6c17426

jarmo commented 9 years ago

Thanks! Using - for stdin works now! I'm gonna close this issue, although multipart uploads are not supported, but i've managed to just upload the content of the file.