Martin Panter added the comment:
Thanks for looking at this. Perhaps you weren’t pasting the HTTP response into
“socat”. After the six request lines are printed out, I enter the five lines
between <HTTP response start> and <HTTP response end>; I didn’t really make
this obvious. Otherwise, urlopen() hangs waiting for the response and read()
never even gets called.
Here’s a Python-only HTTP server to demonstrate without needing “socat”. Run
this in one terminal:
from http.server import HTTPServer, BaseHTTPRequestHandler
class Handler(BaseHTTPRequestHandler):
protocol_version = "HTTP/1.1"
def do_GET(self):
self.send_response(200)
self.send_header("Transfer-Encoding", "chunked")
self.end_headers()
self.wfile.write(b"0\r\n\r\n")
HTTPServer(("", 8000), Handler).serve_forever()
. . . and in another terminal:
from urllib.request import urlopen
with urlopen("http://localhost:8000") as response:
response.read()
import gc; gc.collect()
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19524>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com