题
我正在尝试使用以下命令将 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(继续)响应。更新: 看起来这是可能的,根据 §8.2.3 的 RFC 2616(超文本传输协议 - HTTP/1.1):
如果请求消息不包含带有“ 100 continue”期望的期望值头字段,则Origin服务器不应发送100(继续)响应,并且如果此类请求来自HTTP/1.0(或更早)客户端。此规则有一个例外:与RFC 2068的兼容性, 服务器可能会根据HTTP/1.1 PUT或发布请求发送100(继续)状态,该请求不包括带有“ 100-继续”期望的期望值头字段。 此例外,其目的是最大程度地减少与未申报的任何客户处理延迟,等待100(继续)状态,仅适用于HTTP/1.1请求,而不是与任何其他HTTP-版本值的请求。
卷曲 这样的交易没有任何问题。它发送一个
Expect: 100-Continue
标题并继续对真实的回应进行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 或其他方法来避免遇到此问题。