我正在处理套接字操作,并用python编写了一个基本的拦截代理。它工作正常,但有些主机返回400个错误的请求响应。在
不过,这些请求看起来没有格式错误。这里有一个:
GET http://www.baltour.it/ HTTP/1.1
Host: www.baltour.it
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:28.0) Gecko/20100101 Firefox/28.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
相同的请求,原始:
^{pr2}$我用来发送请求的代码是最基本的socket操作(虽然我不认为问题出在那里,但它在大多数主机上都能正常工作)
socket_client.send(request_raw)
while插座_客户端.recv用于获取响应(但在这里没有问题,响应的格式良好,尽管其状态为400)。在
有什么想法吗?在
不与代理对话时,不应将
http://hostname
部分放在HTTP头中;请参见section 5.1.2 of the HTTP 1.1 RFC 2616 spec:(emphasis mine);
abs_path
是请求URI的绝对路径部分,而不是完整的绝对URI本身。在例如,服务器希望您发送:
但是,接收服务器应该能够容忍不正确的行为。服务器似乎也违反了RFC。在同一节中,它进一步写道:
相关问题 更多 >
编程相关推荐