Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(290)

Unified Diff: python2/httplib2/__init__.py

Issue 7529045: Fix BadStatusLine issue. (Closed)
Patch Set: 80 Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | python2/httplib2test.py » ('j') | python3/httplib2test.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: python2/httplib2/__init__.py
===================================================================
--- a/python2/httplib2/__init__.py
+++ b/python2/httplib2/__init__.py
@@ -1246,7 +1246,10 @@
self.authorizations = []
def _conn_request(self, conn, request_uri, method, body, headers):
- for i in range(RETRIES):
+ i = 0
+ seen_bad_status_line = False
+ while i < RETRIES:
+ i += 1
try:
if hasattr(conn, 'sock') and conn.sock is None:
conn.connect()
@@ -1284,6 +1287,19 @@
continue
try:
response = conn.getresponse()
+ except httplib.BadStatusLine:
+ # If we get a BadStatusLine on the first try then that means
+ # the connection just went stale, so retry regardless of the
+ # number of RETRIES set.
+ if not seen_bad_status_line and i == 1:
+ i = 0
+ seen_bad_status_line = True
+ conn.close()
+ conn.connect()
+ continue
+ else:
+ conn.close()
+ raise
except (socket.error, httplib.HTTPException):
if i < RETRIES-1:
conn.close()
« no previous file with comments | « no previous file | python2/httplib2test.py » ('j') | python3/httplib2test.py » ('J')

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b