theelous3 / asks

Async requests-like httplib for python.
MIT License
508 stars 63 forks source link

close socket after sending request with `connection: close` header #168

Closed RmStorm closed 4 years ago

RmStorm commented 4 years ago

Currently when 'asks' uses a session without connection: keep-alive it relies on the server to send the header connection: close back. So even if 'asks' itself asks the server to close the connection it will try to reuse the connection in the session unless the server sends that header back. This is incorrect since it says in the official W3 standard

https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html Once a close has been signaled, the client MUST NOT send any more requests on that connection.

So 'asks' should close the socket after receiving a response.

theelous3 commented 4 years ago

This has been quiet for a while, so I went ahead and made @rnovatorov 's suggestions and merged. Thanks peeps :)

RmStorm commented 4 years ago

This has been quiet for a while, so I went ahead and made @rnovatorov 's suggestions and merged. Thanks peeps :)

That's great! I never found the time to revisit this PR after making it so I'm happy you went and completed + merged it.