使 mod_proxy_http 异步发回响应(无 100 Continue)

使 mod_proxy_http 异步发回响应(无 100 Continue)

servlet 引擎 (Jetty) 在 Apache Httpd 服务器后面运行,使用 进行转发mod_proxy_http。它运行一个小型 servlet,接受PUT请求并使用 HTTP Basic 身份验证进行身份验证(在 Jetty 内处理)。

PUT当使用错误的身份验证凭据执行直接(非代理)请求时curl,服务器将按预期返回 401 状态代码:

curl -v -T testfile -u user:WRONG_PASSWORD http://localhost:8080/myservlet/

一旦收到状态代码就会中断请求,因此 curl 不会上传整个主体,而是提前停止(HTTP error before end of send, stop sending)。

* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
* Server auth using Basic with user 'user'
> PUT /myservlet/testfile HTTP/1.1
> Authorization: Basic xxxxxxxxxxxxxxxxx
> User-Agent: curl/7.22.0
> Host: localhost:8080
> Accept: */*
> Content-Length: 3672
> Expect: 100-continue
> 
< HTTP/1.1 401 Unauthorized
< Date: xxxxxxxxxxxxxxxx
* Authentication problem. Ignoring this.
< WWW-Authenticate: basic realm="Test Realm"
< Content-Length: 0
< Server: Jetty(7.4.5.v20110725)
* HTTP error before end of send, stop sending
< 
* Closing connection #0

相反,当落后时mod_proxy_http100 ContinueApache Httpd 几乎立即发送响应,而 curl 会将其解释为,因此它会在最终获得响应之前continue发送整个请求( ) 。We are completely uploaded and fine401

*   Trying 127.0.0.1... connected
* Server auth using Basic with user 'user'
> PUT /myservlet/testfile HTTP/1.1
> Authorization: Basic xxxxxxxxxxxxxxxxx
> User-Agent: curl/7.22.0
> Host: localhost
> Accept: */*
> Content-Length: xxxxxx
> Expect: 100-continue
> 
< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 401 Unauthorized
< Date: xxxxxxxxxxxxxxxx
< Server: Jetty(7.4.5.v20110725)
* Authentication problem. Ignoring this.
< WWW-Authenticate: basic realm="Test Realm"
< Content-Length: 0
< Via: 1.1 localhost
< Content-Type: xxxxxxxxxxxxxx
< 
* Connection #0 to host localhost left intact
* Closing connection #0

有没有办法可以防止mod_proxy_http使用该100 Continue代码并让它等待401来自后端服务器的状态代码然后再发送其第一个响应?

我尝试去追随这个问题的以下建议,但这并没有解决问题(反正也不是完全相同的问题):

    ProxyPass /myservlet/ http://localhost:8080/myservlet/
    <Location /myservlet/>
            RequestHeader unset Expect early
    </Location>

相关内容