'Send a request to the server.
`method\' specifies an HTTP request method, e.g. \'GET\'.
`url\' specifies the object being requested, e.g. \'/index.html\'.
`skip_host\' if True does not add automatically a \'Host:\' header
`skip_accept_encoding\' if True does not add automatically an
\'Accept-Encoding:\' header'

def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):

    if (self.__response and self.__response.isclosed()):
        self.__response = None
    if (self.__state == _CS_IDLE):
        self.__state = _CS_REQ_STARTED
    else:
        raise CannotSendRequest()
    self._method = method
    if (not url):
        url = '/'
    hdr = ('%s    %s    %s' % (method, url, self._http_vsn_str))
    self._output(hdr)
    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:
                if self._tunnel_host:
                    host = self._tunnel_host
                    port = self._tunnel_port
                else:
                    host = self.host
                    port = self.port
                try:
                    host_enc = host.encode('ascii')
                except UnicodeEncodeError:
                    host_enc = host.encode('idna')
                if (host_enc.find(':') >= 0):
                    host_enc = (('[' + host_enc) + ']')
                if (port == self.default_port):
                    self.putheader('Host', host_enc)
                else:
                    self.putheader('Host', ('%s:%s' % (host_enc, port)))
        if (not skip_accept_encoding):
            self.putheader('Accept-Encoding', 'identity')
    else:
        pass
