如何使Wget处理HTTP 100-Continue响应?
时间:2020-03-06 14:39:25 来源:igfitidea点击:
我正在尝试使用Wget将HTML(包含在文件中)发布到URL,如下所示:
wget -O- --debug --header=Content-Type:text/html --post-file=index.html http://localhost/www/encoder.ashx
将HTML发布到的URL是使用ASP.NET实现的Web应用程序端点。服务器以100(继续)响应进行响应,而Wget只是停止前进而已,而不是继续接下来应该执行的实际响应。
能否以某种方式告诉Wget回答100(继续)响应,或者这是该工具的一些众所周知的限制?
笔记:
- 我注意到Wget从不发送
Expect:100-Continue
标头,因此从技术上讲,服务器不应发出100(继续)响应。更新:按照RFC 2616(超文本传输协议-HTTP / 1.1)8.2.3的规定,这似乎是可能的:
An origin server SHOULD NOT send a 100 (Continue) response if the request message does not include an Expect request-header field with the "100-continue" expectation, and MUST NOT send a 100 (Continue) response if such a request comes from an HTTP/1.0 (or earlier) client. There is an exception to this rule: for compatibility with RFC 2068, a server MAY send a 100 (Continue) status in response to an HTTP/1.1 PUT or POST request that does not include an Expect request-header field with the "100- continue" expectation. This exception, the purpose of which is to minimize any client processing delays associated with an undeclared wait for 100 (Continue) status, applies only to HTTP/1.1 requests, and not to requests with any other HTTP- version value.
- cURL在这样的事务中没有问题。它发送一个"期望:100-继续"标头,并继续对真实的100(继续)响应。
有关更多信息,这是来自上面显示的调用的事务的完整调试跟踪:
Setting --post-file (postfile) to index.html Setting --header (header) to Content-Type:text/html DEBUG output created by Wget 1.10 on Windows. --13:29:17-- http://localhost/www/encoder.ashx => `-' Resolving localhost... seconds 0.00, 127.0.0.1 Caching localhost => 127.0.0.1 Connecting to localhost|127.0.0.1|:80... seconds 0.00, connected. Created socket 296. Releasing 0x01621a10 (new refcount 1). ---request begin--- POST /www/encoder.ashx HTTP/1.0 User-Agent: Wget/1.10 Accept: */* Host: localhost Connection: Keep-Alive Content-Type: text/html Content-Length: 30984 ---request end--- [writing POST file index.html ... done] HTTP request sent, awaiting response... ---response begin--- HTTP/1.1 100 Continue Server: ASP.NET Development Server/9.0.0.0 Date: Wed, 24 Sep 2008 11:29:17 GMT Content-Length: 0 ---response end--- 100 Continue Closed fd 296 13:29:17 ERROR 100: Continue.
解决方案
我查看了Windows的wget的源代码,据我所知,当wget无法正确解析响应时,调试输出来自一般错误情况。看起来这只是wget的限制,因此我们可能不得不使用curl或者其他方法来避免遇到此问题。