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

Unified Diff: appengine/findit/common/http_client_appengine.py

Issue 1950123003: [Findit] Fetch DEPS from buildspec/ instead of trunk for chrome official builds. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Update doc string. Created 4 years, 7 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
« no previous file with comments | « appengine/findit/common/deps_parser.py ('k') | appengine/findit/common/test/chromium_deps_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/findit/common/http_client_appengine.py
diff --git a/appengine/findit/common/http_client_appengine.py b/appengine/findit/common/http_client_appengine.py
index 171f89773ca132841819695ac99c6f57802b8965..d1edbcc0faa848c9dcc0ab45b36c9fc6415dac41 100644
--- a/appengine/findit/common/http_client_appengine.py
+++ b/appengine/findit/common/http_client_appengine.py
@@ -7,11 +7,20 @@ import logging
from google.appengine.api import urlfetch
+from common import auth_util
from common.retry_http_client import RetryHttpClient
+#TODO(katesonia): Move this to config.
+_INTERNAL_HOSTS = ['https://chrome-internal.googlesource.com/']
+
+
class HttpClientAppengine(RetryHttpClient): # pragma: no cover
"""A http client for running on appengine."""
+
+ def _ExpandAuthorizationHeaders(self, headers):
+ headers['Authorization'] = 'Bearer ' + auth_util.GetAuthToken()
+
def _ShouldLogError(self, status_code):
if not self.no_error_logging_statuses:
return True
@@ -21,6 +30,14 @@ class HttpClientAppengine(RetryHttpClient): # pragma: no cover
# We wanted to validate certificate to avoid the man in the middle.
if not headers:
headers = {}
+
+ # For google internal hosts, expand Oauth2.0 token to headers to authorize
+ # the requests.
+ for host in _INTERNAL_HOSTS:
+ if url.startswith(host):
+ self._ExpandAuthorizationHeaders(headers)
+ break
+
if method in (urlfetch.POST, urlfetch.PUT):
result = urlfetch.fetch(
url, payload=data, method=method,
« no previous file with comments | « appengine/findit/common/deps_parser.py ('k') | appengine/findit/common/test/chromium_deps_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698