Home | History | Annotate | Download | only in common
      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
      3 # found in the LICENSE file.
      4 
      5 class HttpClient(object):
      6   """Represent a http client for sending request to a http[s] server.
      7 
      8   If cookies need to be sent, they should be in a file pointed to by
      9   COOKIE_FILE in the environment.
     10   """
     11 
     12   @staticmethod
     13   def Get(url, params={}, timeout=120, retries=5, retry_interval=0.5,
     14           retry_if_not=None):
     15     """Send a GET request to the given url with the given parameters.
     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 120 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 
     26     Returns:
     27       (status_code, data)
     28       state_code: the http status code in the response.
     29       data: the body of the response.
     30     """
     31     raise NotImplemented()
     32