开发者

POST binary file with cmd line curl using headers contained in the file

开发者 https://www.devze.com 2023-01-22 08:39 出处:网络
I\'m trying to send a binary file to a server over HTTP. The beginning of the file contains headers already

I'm trying to send a binary file to a server over HTTP. The beginning of the file contains headers already

I'm trying to send a file using command line version of curl for windows like so:

C:>curl  -H "Content-Type:application/octet-stream" --data-bi开发者_如何转开发nary @asdf.file http://server:1234/url

Curl is adding headers which cause a 400 Bad Request.

When I run the exact same command using the linux version of curl, the post completes?


Use

curl --header "Content-Type:application/octet-stream" --trace-ascii debugdump.txt --data-binary @asdf.file http://server:1234/url

Or

Install wireshark or fiddler in windows to see the http request that flows over the network.

check the headers and the values being sent. Curl adds few headers by default. These default headers may be incompatible/not-accepted by the http server you connect to in case of windows.

To modify the value of header (added by default), you can add header followed by semi-colon. For example, Content-Type; to set the value null.

0

精彩评论

暂无评论...
验证码 换一张
取 消