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 logging | 5 import logging |
6 | 6 |
7 from google.appengine.api import urlfetch | 7 from google.appengine.api import urlfetch |
8 | 8 |
9 from common.retry_http_client import RetryHttpClient | 9 from common.retry_http_client import RetryHttpClient |
10 | 10 |
11 | 11 |
12 class HttpClientAppengine(RetryHttpClient): # pragma: no cover | 12 class HttpClientAppengine(RetryHttpClient): # pragma: no cover |
13 """A http client for running on appengine.""" | 13 """A http client for running on appengine.""" |
14 | 14 |
15 def _Get(self, url, timeout): | 15 def _Get(self, url, timeout): |
16 # We wanted to validate certificate to avoid the man in the middle. | 16 # We wanted to validate certificate to avoid the man in the middle. |
17 result = urlfetch.fetch(url, deadline=timeout, validate_certificate=True) | 17 result = urlfetch.fetch(url, deadline=timeout, validate_certificate=True) |
18 | 18 |
19 if result.status_code != 200: | 19 if result.status_code != 200: |
20 logging.error('Request to %s failed with code=%d: %s', | 20 logging.error('Request to %s resulted in %d', url, result.status_code) |
21 url, result.status_code, result.content) | |
22 | 21 |
23 return result.status_code, result.content | 22 return result.status_code, result.content |
OLD | NEW |