Re: why the connection set with “keep live” in urllib.request always set to be“closed, thanks

Barry barry at barrys-emacs.org
Mon Aug 17 16:51:03 EDT 2020



> On 17 Aug 2020, at 18:23, xuanwu348 <xuanwu348 at 163.com> wrote:
> 
> hi everyone
> 
> 
> Good day, the code as below, I try to make a long connection by set the connection to "keep-alive", but actually it's not as expected. Why?  Thanks

What this means is. Please web server keep the connect alive if you can.
The web server is allowed to close the connection if it wants too.

Barry

> 
> 
> import urllib.request as req
> headers = {"authorization": "Bearer {}".format(self.token),
>                   "Content-Type": "multipart/form-data; boundary={}".format(self.boundary),
>                   "Connection": "keep-alive"}
> request = req.Request(event_uri, headers=headers, data=data.encode("utf-8"))
> 
> 
> 
> 
> 
> Accept-Encoding: identity
> 
> Content-Length: 705
> 
> Host: 10.10.1.114:9443
> 
> User-Agent: Python-urllib/3.8
> 
> Authorization: Bearer a1.BUiPZxxxxxxxxxxxxxxxxxxCQdH2c9uegml
> 
> Content-Type: multipart/form-data; boundary=--testtest--
> 
> Connection: close
> 
> 
> 
> 
> 
> 
> 
> Best Regards
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list