예제 #1
0
    def putrequest(self,
                   method,
                   url,
                   skip_host=False,
                   skip_accept_encoding=False):
        """Send a request to the server.

    Args:
      method: str Specifies an HTTP request method.
      url: str Specifies the object being requested.
      [optional]
      skip_host: bool If True does not add automatically a 'Host:' header.
      skip_accept_encoding: bool If True does not add automatically an
                            'Accept-Encoding:' header.
    """
        if HttpConnectionHandler.compress: skip_accept_encoding = True
        if self.__http_proxy != self.__host:
            scheme = Utils.GetSchemeFromUrl(url) or 'http'
            netloc = Utils.GetNetLocFromUrl(url) or self.__host
            path = Utils.GetPathFromUrl(url)
            uri = '%s://%s%s' % (scheme, netloc, path)
        else:
            uri = url
        httplib.HTTPConnection.putrequest(
            self,
            method=method,
            url=uri,
            skip_host=skip_host,
            skip_accept_encoding=skip_accept_encoding)