New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
httplib tunnel infinite loop #57893
Comments
readline() can return ''. This is handled in most places in httplib but not when a tunnel is used. It leads to a infinite loop that permanently blocks the program while wasting CPU cycles. For the patch I simply copied the fix that is used elsewhere in the file where readline() is used. It can be fixed in the same way in 2.6. |
In 3.2, http.client.py, insertion would be at line 718. At 313, i found this misformed code: if not line:
# Presumably, the server closed the connection before
# sending a valid response.
raise BadStatusLine(line) [I am curious -- is it really intended to simply throw away the tunnel server response after the first header?] |
Although perhaps not optimal, the patch is consistent with the rest of the code and fixes the reasonably severe issue. Could this patch be applied in lieu of a better one that can come later? |
New changeset 790ae45b52be by Senthil Kumaran in branch '2.7': New changeset 7787a9aebdc6 by Senthil Kumaran in branch '3.2': New changeset f98fb46ff273 by Senthil Kumaran in branch '2.7': New changeset 26631c56d81f by Senthil Kumaran in branch '3.2': New changeset 1acb252a3858 by Senthil Kumaran in branch 'default': New changeset 246abd64e830 by Senthil Kumaran in branch 'default': |
New changeset 685c1db976c4 by Senthil Kumaran in branch '2.7': New changeset afabb0635b15 by Senthil Kumaran in branch '3.2': New changeset cfff6a53f4a3 by Senthil Kumaran in branch 'default': |
I added a simple test for the early eof condition. It is not specific under _tunnel. I find that Mocks yet to be written that cover the response from httplib ( the mocks in the tests -httplib,urllib2), have their own overridden read() method which may not cover this scenario). The early eof test may be helpful to some extent as general test case. I am closing this bug report as fix has been covered. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: