OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 class HttpClient(object): | 5 class HttpClient(object): |
6 """Represent a http client for sending request to a http[s] server. | 6 """Represent a http client for sending request to a http[s] server. |
7 | 7 |
8 If cookies need to be sent, they should be in a file pointed to by | 8 If cookies need to be sent, they should be in a file pointed to by |
9 COOKIE_FILE in the environment. | 9 COOKIE_FILE in the environment. |
10 """ | 10 """ |
11 | 11 |
12 @staticmethod | 12 @staticmethod |
13 def Get(url, params={}, timeout=None): | 13 def Get(url, params={}, timeout=60, retries=5, retry_interval=0.5, |
| 14 retry_if_not=None): |
14 """Send a GET request to the given url with the given parameters. | 15 """Send a GET request to the given url with the given parameters. |
15 | 16 |
| 17 Args: |
| 18 url: the url to send request to. |
| 19 params: parameters to send as part of the http request. |
| 20 timeout: timeout for the http request, default is 60 seconds. |
| 21 retries: indicate how many retries before failing, default is 5. |
| 22 retry_interval: interval in second to wait before retry, default is 0.5. |
| 23 retry_if_not: a http status code. If set, retry only when the failed http |
| 24 status code is a different value. |
| 25 |
16 Returns: | 26 Returns: |
17 (status_code, data) | 27 (status_code, data) |
18 state_code: the http status code in the response. | 28 state_code: the http status code in the response. |
19 data: the body of the response. | 29 data: the body of the response. |
20 """ | 30 """ |
21 raise NotImplemented() | 31 raise NotImplemented() |
OLD | NEW |