Martin Panter added the comment:
As I see it, if the client receives an early response (when 100-continue is not
used) but needs to make more requests, the only choices are:
* Complete sending the request if possible, after which the connection may
still be usable for a second request. But I’m not sure how many servers would
support this; for your Microsoft server this would not be useful.
* Abort the connection and start a new one.
Perhaps the race condition would be more obvious if you sent the upload as a
single 300 MiB bytes() object rather than a file. Then the sendall() call will
be a 300 MiB chunk rather than 8 KiB. If the response is received after
sendall() starts, I expect you will see the original two minute delay again. If
this were plain TCP, you could replace sendall() with fine-grained select() and
send() calls in a loop.
Here is a demonstration of the SSL renegotiation issue. I used separate client
and server terminal windows. I don’t know if there is a way to force
renegotiation purely in Python’s SSL module, so I used an external Open SSL
server.
1: In the server window, start an SSL server on port 4433:
$ openssl s_server -cert Lib/test/keycert.pem
2: In the client window, start a request in the Python interpreter. It will
pause to read stdin:
>>> import http.client, ssl, sys
>>> context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
>>> context.load_verify_locations("/usr/lib/python3.5/test/keycert.pem")
>>> conn = http.client.HTTPSConnection('localhost', 4433, context=context)
>>> conn.request("PUT", "/", headers={"Content-Length": "4"},
>>> body=sys.stdin.buffer)
3: In the server, the request header is received. Type lowercase “r” to force a
renegotiation:
Secure Renegotiation IS supported
PUT / HTTP/1.1
Host: localhost:4433
Accept-Encoding: identity
Content-Length: 8
r
SSL_do_handshake -> 1
4: In Python, type in upload data and repeat Ctrl+D to signal EOF until the
request() call stops reading from stdin and you get the Python prompt back:
abc <== 3 letters + newline + Ctrl+D
>>>
5: Notice that the no body has been uploaded to the server.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue25919>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com