--- httplib.py Tue Jul 27 20:49:54 2004 +++ httplib.py.fixed Tue Jul 27 20:06:40 2004 @@ -728,15 +728,17 @@ self._send_request(method, url, body, headers) def _send_request(self, method, url, body, headers): - # If headers already contains a host header, then define the - # optional skip_host argument to putrequest(). The check is - # harder because field names are case insensitive. - if 'host' in [k.lower() for k in headers]: - self.putrequest(method, url, skip_host=1) - else: - self.putrequest(method, url) + # honour explicitly requested Host: and Accept-Encoding headers + header_names = [k.lower() for k in headers] + skips = {} + if 'host' in header_names: + skips['skip_host'] = 1 + if 'accept-encoding' in header_names: + skips['skip_accept_encoding'] = 1 - if body: + self.putrequest(method, url, **skips) + + if body and ('content-length' not in header_names): self.putheader('Content-Length', str(len(body))) for hdr, value in headers.iteritems(): self.putheader(hdr, value)