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

Side by Side Diff: chrome/common/extensions/docs/server2/appengine_url_fetcher.py

Issue 297963004: Docserver: Update app version parsing since AppEngine started including / (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import base64 5 import base64
6 import posixpath 6 import posixpath
7 7
8 from appengine_wrappers import GetAppVersion, urlfetch 8 from appengine_wrappers import urlfetch
9 from environment import GetAppVersion
9 from future import Future 10 from future import Future
10 11
11 12
12 def _MakeHeaders(username, password): 13 def _MakeHeaders(username, password):
13 headers = { 14 headers = {
14 'User-Agent': 'Chromium docserver %s' % GetAppVersion(), 15 'User-Agent': 'Chromium docserver %s' % GetAppVersion(),
15 'Cache-Control': 'max-age=0', 16 'Cache-Control': 'max-age=0',
16 } 17 }
17 if username is not None and password is not None: 18 if username is not None and password is not None:
18 headers['Authorization'] = 'Basic %s' % base64.b64encode( 19 headers['Authorization'] = 'Basic %s' % base64.b64encode(
(...skipping 22 matching lines...) Expand all
41 urlfetch.make_fetch_call(rpc, 42 urlfetch.make_fetch_call(rpc,
42 self._FromBasePath(url), 43 self._FromBasePath(url),
43 headers=_MakeHeaders(username, password)) 44 headers=_MakeHeaders(username, password))
44 return Future(callback=lambda: rpc.get_result()) 45 return Future(callback=lambda: rpc.get_result())
45 46
46 def _FromBasePath(self, url): 47 def _FromBasePath(self, url):
47 assert not url.startswith('/'), url 48 assert not url.startswith('/'), url
48 if self._base_path is not None: 49 if self._base_path is not None:
49 url = posixpath.join(self._base_path, url) if url else self._base_path 50 url = posixpath.join(self._base_path, url) if url else self._base_path
50 return url 51 return url
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/app.yaml ('k') | chrome/common/extensions/docs/server2/appengine_wrappers.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698