Ticket #392: httpserver.py.diff

File httpserver.py.diff, 1.8 KB (added by dalke, 2 years ago)

patch to httpserver.py

  • lib/thirdparty/httpserver.py

    diff -r 2fccd121e818 lib/thirdparty/httpserver.py
    a b  
    324324                self.wsgi_write_chunk("Internal Server Error\n") 
    325325            raise 
    326326 
     327 
     328class _HTTPServer(HTTPServer): 
     329    def server_bind(self): 
     330        if self.RequestHandlerClass.protocol_version == "HTTP/1.1": 
     331            # Disable Nagle's Algorithm, which causes performance 
     332            # problems with Keep-Alive. Sometimes the server has sent 
     333            # a response to the client but the TCP stack buffers the 
     334            # response in hopes of reducing the number of packets to 
     335            # send. After about 200ms it gives up and sends the rest 
     336            # of the packet, but 0.2s is a long time to wait when 
     337            # there are many small, fast requests on the same 
     338            # connection. 
     339            self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) 
     340        HTTPServer.server_bind(self) 
     341 
    327342# 
    328343# SSL Functionality 
    329344# 
     
    338353    # functionality in that case. 
    339354    SSL = None 
    340355    SocketErrors = (socket.error,) 
    341     class SecureHTTPServer(HTTPServer): 
     356    class SecureHTTPServer(_HTTPServer): 
    342357        def __init__(self, server_address, RequestHandlerClass, 
    343358                     ssl_context=None, request_queue_size=None): 
    344359            assert not ssl_context, "pyOpenSSL not installed" 
     
    356371        def __getattr__(self, attrib): 
    357372            return getattr(self.__conn, attrib) 
    358373 
    359     class SecureHTTPServer(HTTPServer): 
     374    class SecureHTTPServer(_HTTPServer): 
    360375        """ 
    361376        Provides SSL server functionality on top of the BaseHTTPServer 
    362377        by overriding _private_ members of Python's standard