0

我正在尝试使用 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 Expectation Failed。我只是在学习 curl,我不确定该怎么做。我是否需要尽可能地模拟浏览器命令的标题?或者边界是什么可能把它扔掉?谢谢你的帮助。

4

1 回答 1

1

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

于 2013-10-22T01:02:23.093 回答