【问题标题】:How to make Wget handle an HTTP 100-Continue response?如何让 Wget 处理 HTTP 100-Continue 响应?
【发布时间】:2010-09-12 16:57:14
【问题描述】:

我正在尝试使用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 (Continue) 响应,Wget 只是停止在其轨道上,而不是继续应该接下来跟随的真实响应。

是否可以以某种方式告诉 Wget 处理 100(继续)响应,或者这是该工具的一些众所周知的限制?

注意事项:

  • 我注意到 Wget 从不发送 Expect: 100-Continue 标头所以 从技术上讲,服务器不应该 发出 100(继续)响应。

    更新:看起来这是可能的,根据§8.2.3 RFC 2616 (Hypertext Transfer Protocol -- HTTP/1.1):

    如果出现以下情况,源服务器不应发送 100(继续)响应 请求消息不包含 Expect 请求标头 具有“100-continue”期望的字段,并且不得发送 如果此类请求来自 HTTP/1.0,则为 100(继续)响应 (或更早的)客户。这条规则有一个例外:对于 与 RFC 2068 的兼容性,服务器可以发送 100(继续) 响应 HTTP/1.1 PUT 或 POST 请求的状态 不包括带有“100-”的 Expect 请求标头字段 继续”的期望。 这个异常,其目的是 最大限度地减少与一个相关的任何客户端处理延迟 未声明的等待 100(继续)状态,仅适用于 HTTP/1.1 请求,而不是与任何其他 HTTP- 的请求 版本值。

  • cURL 这样的交易没有问题。 它发送一个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.

【问题讨论】:

    标签: http wget


    【解决方案1】:

    我查看了适用于 Windows 的 wget 的源代码,据我所知,当 wget 无法正确解析响应时,调试输出来自一般错误条件。看起来这只是 wget 的一个限制,所以你可能不得不使用 curl 或其他一些方法来避免遇到这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多