无法通过 Squid 代理测试基于 HTTP PUT 的文件上传

2024-01-12

我可以使用 Curl 将文件上传到我的 Apache Web 服务器:

echo "[$(date)] file contents." | curl -T - http://WEB-SERVER/upload/sample.put 

但是,如果我在中间放置一个 Squid 代理服务器,那么我将无法:

echo "[$(date)] file contents." | curl -x http://SQUID-PROXY:3128 -T - http://WEB-SERVER/upload/sample.put 

Curl 报告以下错误:

注意:此错误响应采用 HTML 格式,但为了便于阅读,我已删除标签。

ERROR: The requested URL could not be retrieved

ERROR
The requested URL could not be retrieved

While trying to retrieve the URL:
http://WEB-SERVER/upload/sample.put

The following error was encountered:
Unsupported Request Method and Protocol

Squid does not support all request methods for all access protocols.
For example, you can not POST a Gopher request.
Your cache administrator is root. 

My squid.conf似乎没有任何 ACL/规则应该禁止基于src or dstIP 地址,或protocol,或 HTTPmethod... 我可以做HTTP POST在同一个客户端和 Web 服务器之间就好了,中间有相同的代理。

万一失败HTTP PUT案例中,为了查看实际发生的请求和响应流量,我放置了netcatCurl 和 Squid 之间的过程,这就是我所看到的:

Request:

PUT http://WEB-SERVER/upload/sample.put HTTP/1.1
User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: WEB-SERVER
Pragma: no-cache
Accept: */*
Proxy-Connection: Keep-Alive
Transfer-Encoding: chunked
Expect: 100-continue

回复:

HTTP/1.0 501 Not Implemented
Server: squid/2.6.STABLE21
Date: Sun, 13 May 2012 02:11:39 GMT
Content-Type: text/html
Content-Length: 1078
Expires: Sun, 13 May 2012 02:11:39 GMT
X-Squid-Error: ERR_UNSUP_REQ 0
X-Cache: MISS from SQUID-PROXY-FQDN
X-Cache-Lookup: NONE from SQUID-PROXY-FQDN:3128
Via: 1.0 SQUID-PROXY-FQDN:3128 (squid/2.6.STABLE21)
Proxy-Connection: close

<SNIPPED the HTML error response already shown earlier above>

注意:出于可读性原因,我对 IP 地址和服务器名称进行了匿名处理。


感谢 Amos Jeffries 对此问题的回答鱿鱼用户论坛 http://squid-web-proxy-cache.1019090.n4.nabble.com/Unable-to-test-HTTP-PUT-based-file-upload-via-Squid-Proxy-td4634404.html。问题基本上是 3.1 版本之前的 Squid 没有实现 HTTP 1.1,因此拒绝分块传输编码。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法通过 Squid 代理测试基于 HTTP PUT 的文件上传 的相关文章

随机推荐