【发布时间】:2012-05-13 01:20:28
【问题描述】:
我可以使用 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.
我的squid.conf 似乎没有任何基于src 或dst IP 地址、protocol 或HTTP method 的ACL/规则... 因为我可以在同一个客户端和 Web 服务器之间使用 HTTP POST 就可以了,中间使用同一个代理。
在HTTP PUT 失败的情况下,为了查看实际发生的请求和响应流量,我在Curl 和Squid 之间放置了一个netcat 进程,这就是我所看到的:
请求:
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 地址和服务器名称进行了匿名处理。
【问题讨论】:
-
我认为问题出在 Expect 标头上。你能把它去掉吗?因为 Squid 支持 PUT 方法。
-
我尝试了(使用
-H "Expect:"选项)但仍然是相同的响应。
标签: http upload proxy squid put