Squid - 400 on POST request

2019-09-07 21:21发布

问题:

The following HTTP request returns a 400 ERR_INVALID_REQ -

POST http://distservp1.pb.com/dstproduct.asp HTTP/1.1 
Proxy-Authorization: Basic Og==
Host: distservp1.pb.com
Connection: close
Content-type: application/x-www-form-urlencoded
Content-length: 638

PBXML=%3CSignonReq%3E%0D%0A%0...

The response (body contains no additional information)-

HTTP/1.0 400 Bad Request
Server: squid/2.7.STABLE8
Date: Wed, 04 Jan 2017 09:07:16 GMT
Content-Type: text/html
Content-Length: 2054
X-Squid-Error: ERR_INVALID_REQ 0
X-Cache: MISS from [ProxyName].local
X-Cache-Lookup: NONE from [ProxyName].local:8080
Via: 1.0 [ProxyName].local:8080 (squid/2.7.STABLE8)
Connection: close

Looking at a packet capture the body of the POST request is sent in two PDUs. The 400 is sent back before the second PDU is sent - so I would imagine the error lies int he headers. The Squid cache.log just shows -

clientTryParseRequest: FD 20 (192.168.120.72:49503) Invalid Request

A similar request generated from the DHC plugin in chrome succeeds -

POST http://distservp1.pb.com/dstproduct.asp HTTP/1.1
Host: distservp1.pb.com
Proxy-Connection: keep-alive
Content-Length: 638
Origin: chrome-extension://aejoelaoggembcahagimdiliamlcdmfm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8

Can anyone see what is going wrong here? And any ideas on how to fix it? We are not able to modify the application which is sending the request. It works fine on a device not routed through the proxy.

回答1:

Turns out the application in question is adding a space character at the end of the request line. This causes Squid to reject it.



标签: http squid