卷曲标题信息

时间:2013-10-22 00:47:45

标签: http curl

我正在尝试使用curl将数据上传到网络服务器。我已经使用wireshark分析了从浏览器发送到服务器的数据,如下所示:

POST /cgi-bin/upload.cgi HTTP/1.1
Host: 192.168.1.22
Connection: keep-alive
Content-Length: 2637
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Origin: http://192.168.1.22
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) 
Chrome/30.0.1599.101 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryn1sckmiVOVfCwUMQ
Referer: http://192.168.1.22/upload.html
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8

我查看了浏览器访问的网页以上传信息,如下所示:

<form method="POST" enctype="multipart/form-data" action="http://192.168.1.22/cgi-bin/upload.cgi">
File to upload: 
<input type="file" name="theupload"><br>
Should it be updated?<input type="checkbox" name="configuration"><br>
<input type="submit" value="Press"> to upload the file!
</form>

我试图使用:

curl --referer http://192.168.1.22/upload.html -F theupload=@file1.xml -F config=on http://192.168.1.22:80/cgi-bin/upload.cgi

我的输出是

POST /cgi-bin/upload.cgi HTTP/1.1
User-Agent: curl/7.33.0
Host: 192.168.1.22
Accept: */*
Referer: http://192.168.1.22/upload.html
Content-Length: 2650
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------fd126312049d1f47

服务器返回 HTTP / 1.1 417期望失败。 我只是在学习卷曲,我不确定该怎么做。我是否需要尽可能地模拟浏览器命令的标题?或者是边界可能会把它扔掉? 谢谢你的帮助。

1 个答案:

答案 0 :(得分:1)

尝试使用curl -H "Expect:" ...