Skip to content Skip to sidebar Skip to footer

How To Close The Connection

I'm migrating a simple toolset from python 2.7 to 3.5 and one of the tools is a simple web server using web.py. Unfortunately web.py is not available for 3.5 yet so I switched to b

Solution 1:

I'm not sure so take what I write with a grain of salt.

The bottle development server is a lightly modified wsgiref server which is a sligthly modified http.server server. It has no easy methods or configurations to send "unusual" headers. You can though subclass it and write some custom code. I think it should be enough to overwrite the send_head method (here) and include self.send_header("Connection", "close") somewhere.

You can use bottly with any wsgi server you like. It has inbuild support for quite some servers, but any wsgi server should be able to serve the app. Maybe there is an easier way for other servers to send the custom header.

Also the http.server is not meant for production so you might want to change it even if you can get your header to work. If it is only for internal usage you might get away with using it.

Post a Comment for "How To Close The Connection"