无法通过Squid代理测试基于HTTP PUT的文件上传 [英] Unable to test HTTP PUT-based file upload via Squid Proxy
问题描述
我可以使用Curl将文件上传到我的Apache Web服务器上:
I can upload a file to my Apache web server using Curl just fine:
echo "[$(date)] file contents." | curl -T - http://WEB-SERVER/upload/sample.put
但是,如果我在两者之间放置一个Squid代理服务器,那么我将无法:
However, if I put a Squid proxy server in between, then I am not able to:
echo "[$(date)] file contents." | curl -x http://SQUID-PROXY:3128 -T - http://WEB-SERVER/upload/sample.put
Curl报告以下错误:
Curl reports the following error:
注意:此错误响应为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.
我的 squid.conf
似乎没有基于 src
或 dst
IP地址应禁止的ACL/规则或 protocol
或HTTP method
... ,因为我可以在同一客户端和Web服务器,并且两者之间有相同的代理服务器.
My squid.conf
doesn't seem to be having any ACL/rule that should disallow based on the src
or dst
IP addresses, or the protocol
, or the HTTP method
... as I can do an HTTP POST
just fine between the same client and the web server, with the same proxy sitting in between.
在 HTTP PUT
失败的情况下,为了查看实际发生的请求和响应流量,我在Curl和Squid之间放置了一个 netcat
进程,并且这就是我所看到的:
In case of the failing HTTP PUT
case, to see the request and response traffic that was actually occurring, I placed a netcat
process in between Curl and Squid, and this is what I saw:
请求:
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地址和服务器名称进行匿名化.
推荐答案
Thanks to Amos Jeffries for answering this on squid-users forum. The issue is basically that Squid before version 3.1 does not implement HTTP 1.1 and thus rejects the chunked transfer encoding.
这篇关于无法通过Squid代理测试基于HTTP PUT的文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!