Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 json | 5 import json |
| 6 import logging | 6 import logging |
| 7 | 7 |
| 8 from google.appengine.api import urlfetch | 8 from google.appengine.api import urlfetch |
| 9 | 9 |
| 10 from common import auth_util | 10 from common import auth_util |
| 11 from common.retry_http_client import RetryHttpClient | 11 from libs.http.retry_http_client import RetryHttpClient |
| 12 | 12 |
| 13 | 13 |
| 14 # TODO(katesonia): Move this to config. | 14 # TODO(katesonia): Move this to config. |
| 15 _INTERNAL_HOSTS_TO_SCOPES = { | 15 _INTERNAL_HOSTS_TO_SCOPES = { |
| 16 'https://chrome-internal.googlesource.com/': ( | 16 'https://chrome-internal.googlesource.com/': ( |
| 17 'https://www.googleapis.com/auth/gerritcodereview'), | 17 'https://www.googleapis.com/auth/gerritcodereview'), |
| 18 'https://codereview.chromium.org/': ( | 18 'https://codereview.chromium.org/': ( |
| 19 'https://www.googleapis.com/auth/userinfo.email'), | 19 'https://www.googleapis.com/auth/userinfo.email'), |
| 20 } | 20 } |
| 21 | 21 |
| 22 | 22 |
| 23 class HttpClientAppengine(RetryHttpClient): # pragma: no cover | 23 class HttpClientAppengine(RetryHttpClient): # pragma: no cover |
|
chanli
2016/11/10 23:04:04
Why does this http_client_appengine stay with Find
wrengr
2016/11/11 00:06:45
If you're referring to the "findit" string that oc
stgao
2016/11/14 23:30:51
We will work on the file moving incrementally, not
| |
| 24 """A http client for running on appengine.""" | 24 """A http client for running on appengine.""" |
| 25 | 25 |
| 26 def __init__(self, follow_redirects=True, *args, **kwargs): | 26 def __init__(self, follow_redirects=True, *args, **kwargs): |
| 27 super(HttpClientAppengine, self).__init__(*args, **kwargs) | 27 super(HttpClientAppengine, self).__init__(*args, **kwargs) |
| 28 self.follow_redirects = follow_redirects | 28 self.follow_redirects = follow_redirects |
| 29 | 29 |
| 30 def _ExpandAuthorizationHeaders(self, headers, scope): | 30 def _ExpandAuthorizationHeaders(self, headers, scope): |
| 31 headers['Authorization'] = 'Bearer ' + auth_util.GetAuthToken(scope) | 31 headers['Authorization'] = 'Bearer ' + auth_util.GetAuthToken(scope) |
| 32 | 32 |
| 33 def _ShouldLogError(self, status_code): | 33 def _ShouldLogError(self, status_code): |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 return result.status_code, result.content | 65 return result.status_code, result.content |
| 66 | 66 |
| 67 def _Get(self, url, timeout, headers): | 67 def _Get(self, url, timeout, headers): |
| 68 return self._SendRequest(url, urlfetch.GET, None, timeout, headers) | 68 return self._SendRequest(url, urlfetch.GET, None, timeout, headers) |
| 69 | 69 |
| 70 def _Post(self, url, data, timeout, headers): | 70 def _Post(self, url, data, timeout, headers): |
| 71 return self._SendRequest(url, urlfetch.POST, data, timeout, headers) | 71 return self._SendRequest(url, urlfetch.POST, data, timeout, headers) |
| 72 | 72 |
| 73 def _Put(self, url, data, timeout, headers): | 73 def _Put(self, url, data, timeout, headers): |
| 74 return self._SendRequest(url, urlfetch.PUT, data, timeout, headers) | 74 return self._SendRequest(url, urlfetch.PUT, data, timeout, headers) |
| OLD | NEW |