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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
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.retry_http_client import RetryHttpClient 10 from common.retry_http_client import RetryHttpClient
11 11
12 12
13 class HttpClientAppengine(RetryHttpClient): # pragma: no cover 13 class HttpClientAppengine(RetryHttpClient): # pragma: no cover
14 """A http client for running on appengine.""" 14 """A http client for running on appengine."""
15 def _ShouldLogError(self, status_code): 15 def _ShouldLogError(self, status_code):
16 if not self.no_error_logging_statuses: 16 if not self.no_error_logging_statuses:
17 return True 17 return True
18 return status_code not in self.no_error_logging_statuses 18 return status_code not in self.no_error_logging_statuses
19 19
20 def _SendRequest(self, url, method, data, timeout, headers=None): 20 def _SendRequest(self, url, method, data, timeout, headers=None):
21 # We wanted to validate certificate to avoid the man in the middle. 21 # We wanted to validate certificate to avoid the man in the middle.
22 if not headers: 22 if not headers:
23 headers = {} 23 headers = {}
24
24 if method in (urlfetch.POST, urlfetch.PUT): 25 if method in (urlfetch.POST, urlfetch.PUT):
25 result = urlfetch.fetch( 26 result = urlfetch.fetch(
26 url, payload=data, method=method, 27 url, payload=data, method=method,
27 headers=headers, deadline=timeout, validate_certificate=True) 28 headers=headers, deadline=timeout, validate_certificate=True)
28 else: 29 else:
29 result = urlfetch.fetch( 30 result = urlfetch.fetch(
30 url, headers=headers, deadline=timeout, validate_certificate=True) 31 url, headers=headers, deadline=timeout, validate_certificate=True)
31 32
32 if (result.status_code != 200 and self._ShouldLogError(result.status_code)): 33 if (result.status_code != 200 and self._ShouldLogError(result.status_code)):
33 logging.error('Request to %s resulted in %d, headers:%s', url, 34 logging.error('Request to %s resulted in %d, headers:%s', url,
34 result.status_code, json.dumps(result.headers.items())) 35 result.status_code, json.dumps(result.headers.items()))
35 36
36 return result.status_code, result.content 37 return result.status_code, result.content
37 38
38 def _Get(self, url, timeout, headers): 39 def _Get(self, url, timeout, headers):
39 return self._SendRequest(url, urlfetch.GET, None, timeout, headers) 40 return self._SendRequest(url, urlfetch.GET, None, timeout, headers)
40 41
41 def _Post(self, url, data, timeout, headers): 42 def _Post(self, url, data, timeout, headers):
42 return self._SendRequest(url, urlfetch.POST, data, timeout, headers) 43 return self._SendRequest(url, urlfetch.POST, data, timeout, headers)
43 44
44 def _Put(self, url, data, timeout, headers): 45 def _Put(self, url, data, timeout, headers):
45 return self._SendRequest(url, urlfetch.PUT, data, timeout, headers) 46 return self._SendRequest(url, urlfetch.PUT, data, timeout, headers)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698