

def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
    "Send a request to the server.\n\n        `method' specifies an HTTP request method, e.g. 'GET'.\n        `url' specifies the object being requested, e.g. '/index.html'.\n        `skip_host' if True does not add automatically a 'Host:' header\n        `skip_accept_encoding' if True does not add automatically an\n           'Accept-Encoding:' header\n        "
    if (self.__response and self.__response.isclosed()):
        self.__response = None
    if (self.__state == _CS_IDLE):
        self.__state = _CS_REQ_STARTED
    else:
        raise CannotSendRequest(self.__state)
    self._method = method
    if (not url):
        url = '/'
    request = ('%s %s %s' % (method, url, self._http_vsn_str))
    self._output(request.encode('ascii'))
    if (self._http_vsn == 11):
        if (not skip_host):
            netloc = ''
            if url.startswith('http'):
                (nil, netloc, nil, nil, nil) = urlsplit(url)
            if netloc:
                try:
                    netloc_enc = netloc.encode('ascii')
                except UnicodeEncodeError:
                    netloc_enc = netloc.encode('idna')
                self.putheader('Host', netloc_enc)
            else:
                try:
                    host_enc = self.host.encode('ascii')
                except UnicodeEncodeError:
                    host_enc = self.host.encode('idna')
                if (self.host.find(':') >= 0):
                    host_enc = bytes(((b'[' + host_enc) + b']'))
                if (self.port == self.default_port):
                    self.putheader('Host', host_enc)
                else:
                    host_enc = host_enc.decode('ascii')
                    self.putheader('Host', ('%s:%s' % (host_enc, self.port)))
        if (not skip_accept_encoding):
            self.putheader('Accept-Encoding', 'identity')
    else:
        pass

dataset/ETHPy150Open OpenCobolIDE/OpenCobolIDE/open_cobol_ide/extlibs/future/backports/http/client.py HTTPConnection.putrequest/original