◐ Shell
clean mode source ↗

Message 243751 - Python tracker

Hi again,

first of all, sorry for not contributing to the discussion for such a long time.  I was quite busy lately.

I tested the patch with Python 3.5.0a3.  It works nicely for my use case.  Thanks a lot!

I have one issue though: urllib's HTTPHandler and HTTPSHandler still try to enforce a Content-length to be set (by AbstractHTTPHandler.do_request_()).  But for chunked transfer encoding, the Content-length must not be set.  Using to this patch, HTTPConnection also checks for the Content-length in _send_request() and sets it if missing.  AFAICS, HTTPConnection now does a far better job checking this then HTTPHandler and - most importantly - does it in a way that is compatible with chunked transfer encoding.  So, I would suggest, that there is no need for HTTPHandler to care about the content length and that it should just leave this header alone.

E.g., I suggest that the "if not request.has_header('Content-length'): [...]" statement should completely be removed from AbstractHTTPHandler.do_request_() in urllib/request.py.