我使用 Apache2 作为代理时遇到了问题。我的软件使用以下方式发送受保护资源的 HTTP PUT:
Expect: 100-continue
Transfer-Encoding: chunked
我没有收到“401 Unauthorized”,而是收到了“100 Continue”。之后我的软件将所有块发送到服务器,然后我收到 401。
看起来 Apache 不会转发标题并自动发送“100 Continue”。
这是正确的行为吗?
以下是我发现的内容这里
If a proxy receives a request that includes an Expect request-
header field with the "100-continue" expectation, and the proxy
either knows that the next-hop server complies with HTTP/1.1 or
higher, or does not know the HTTP version of the next-hop
server, it MUST forward the request, including the Expect header
field
答案1
这个问题已经在 stackoverflow.com 上提出过 (https://stackoverflow.com/questions/3889574/apache-and-mod-proxy-not-handling-http-100-continue-from-client-http-417):
您可以按如下方式配置:
<IfModule mod_headers.c>
RequestHeader unset Expect early
</IfModule>
这将删除 Expect 标头,并且通信应该可以正常工作。
编辑 请确保远程端是 HTTP/1.1。在您链接的同一个 RFC 中,引用以下内容后只有一个页面:
- If the proxy knows that the version of the next-hop server is
HTTP/1.0 or lower, it MUST NOT forward the request, and it MUST
respond with a 417 (Expectation Failed) status.