gpt4 book ai didi

http - 如何让 Wget 处理 HTTP 100-Continue 响应?

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:21:06 25 4
gpt4 key购买 nike

我正在尝试使用 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 header 所以从技术上讲,服务器不应该发出 100(继续)响应。

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

    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这样的交易没有问题。它发送一个 Expect: 100-Continue header 并继续 100 (Continue) 响应到真实的。

有关更多信息,这里是来自上面显示的调用的事务的完整调试跟踪:

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 或其他一些方法来避免遇到此问题。

关于http - 如何让 Wget 处理 HTTP 100-Continue 响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/126711/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com