POST二进制文件与cmd行curl使用包含在文件中的头 [英] POST binary file with cmd line curl using headers contained in the file

查看:241
本文介绍了POST二进制文件与cmd行curl使用包含在文件中的头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过HTTP将二进制文件发送到服务器。文件的开头已经包含头



我试图使用curl的命令行版本发送文件,如下所示:



C:> curl -HContent-Type:application / octet-stream--data-binary @ asdf.file http:// server:1234 / url



Curl正在添加会导致400错误请求的标头。



当我使用curl的linux版本运行完全相同的命令时,该文章是否完成?

解决方案

使用

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

>

在windows中安装wireshark或fiddler以查看通过网络传递的http请求。



检查标题和值发送。 Curl默认添加了很少的标题。这些默认标头可能与Windows连接的http服务器不兼容/不接受。



要修改标题的值(默认添加),您可以添加标题后跟分号。例如, Content-Type; 将值设置为null。


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-binary @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.

这篇关于POST二进制文件与cmd行curl使用包含在文件中的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆