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

Unified Diff: chrome/common/extensions/docs/server2/appengine_url_fetcher.py

Issue 491653002: Docserver: Use GitilesFileSystem instead of SubversionFileSystem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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: chrome/common/extensions/docs/server2/appengine_url_fetcher.py
diff --git a/chrome/common/extensions/docs/server2/appengine_url_fetcher.py b/chrome/common/extensions/docs/server2/appengine_url_fetcher.py
index a4c359b6a3baf5388ea12b0bbfba2b1d97dbf619..c9a94b0632478a422a5039964f834bc6d6b970be 100644
--- a/chrome/common/extensions/docs/server2/appengine_url_fetcher.py
+++ b/chrome/common/extensions/docs/server2/appengine_url_fetcher.py
@@ -10,7 +10,7 @@ from environment import GetAppVersion
from future import Future
-def _MakeHeaders(username, password):
+def _MakeHeaders(username, password, access_token):
headers = {
'User-Agent': 'Chromium docserver %s' % GetAppVersion(),
'Cache-Control': 'max-age=0',
@@ -18,6 +18,8 @@ def _MakeHeaders(username, password):
if username is not None and password is not None:
headers['Authorization'] = 'Basic %s' % base64.b64encode(
'%s:%s' % (username, password))
+ if access_token is not None:
+ headers['Authorization'] = 'OAuth %s' % access_token
return headers
@@ -29,19 +31,24 @@ class AppEngineUrlFetcher(object):
assert base_path is None or not base_path.endswith('/'), base_path
self._base_path = base_path
- def Fetch(self, url, username=None, password=None):
+ def Fetch(self, url, username=None, password=None, access_token=None):
"""Fetches a file synchronously.
"""
return urlfetch.fetch(self._FromBasePath(url),
- headers=_MakeHeaders(username, password))
+ deadline=20,
+ headers=_MakeHeaders(username,
+ password,
+ access_token))
- def FetchAsync(self, url, username=None, password=None):
+ def FetchAsync(self, url, username=None, password=None, access_token=None):
"""Fetches a file asynchronously, and returns a Future with the result.
"""
- rpc = urlfetch.create_rpc()
+ rpc = urlfetch.create_rpc(deadline=20)
urlfetch.make_fetch_call(rpc,
self._FromBasePath(url),
- headers=_MakeHeaders(username, password))
+ headers=_MakeHeaders(username,
+ password,
+ access_token))
return Future(callback=lambda: rpc.get_result())
def _FromBasePath(self, url):

Powered by Google App Engine
This is Rietveld 408576698