Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Unified Diff: tools/findit/common/http_client_local.py

Issue 504443004: [Findit] Improve output format and cherry-pick bugs fix. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/findit/common/http_client_local.py
diff --git a/tools/findit/common/http_client_local.py b/tools/findit/common/http_client_local.py
index bf386f9a3968ddbc183ca3687ac570d2bbff9f56..d56dc768ed2a7f9aa156b9d9f9d04ac5c57ae36d 100644
--- a/tools/findit/common/http_client_local.py
+++ b/tools/findit/common/http_client_local.py
@@ -205,11 +205,23 @@ def _SendRequest(url, timeout=None):
urllib2.HTTPCookieProcessor(cookielib.MozillaCookieJar(cookie_file)))
url_opener = urllib2.build_opener(*handlers)
- if timeout is not None:
- response = url_opener.open(url, timeout=timeout)
- else:
- response = url_opener.open(url)
- return response.code, response.read()
+
+ status_code = None
+ content = None
+
+ try:
+ if timeout is not None:
aarya 2014/08/26 19:01:23 None timeout is just ignored, i dont think you nee
stgao 2014/08/26 20:30:47 Nice. That makes the code cleaner.
+ response = url_opener.open(url, timeout=timeout)
+ else:
+ response = url_opener.open(url)
+
+ status_code = response.code
+ content = response.read()
+ except urllib2.HTTPError as e:
+ status_code = e.code
+ content = None
+
+ return status_code, content
class HttpClientLocal(http_client.HttpClient):

Powered by Google App Engine
This is Rietveld 408576698