mirror of
				https://github.com/python/cpython.git
				synced 2025-11-03 15:11:34 +00:00 
			
		
		
		
	gh-134168: fix http.server CLI support for IPv6 and --directory when serving over HTTPS (#134169)
				
					
				
			This commit is contained in:
		
							parent
							
								
									5d9c8fe3f6
								
							
						
					
					
						commit
						2fd09b0110
					
				
					 2 changed files with 13 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -980,8 +980,8 @@ def test(HandlerClass=BaseHTTPRequestHandler,
 | 
			
		|||
    HandlerClass.protocol_version = protocol
 | 
			
		||||
 | 
			
		||||
    if tls_cert:
 | 
			
		||||
        server = ThreadingHTTPSServer(addr, HandlerClass, certfile=tls_cert,
 | 
			
		||||
                                      keyfile=tls_key, password=tls_password)
 | 
			
		||||
        server = ServerClass(addr, HandlerClass, certfile=tls_cert,
 | 
			
		||||
                             keyfile=tls_key, password=tls_password)
 | 
			
		||||
    else:
 | 
			
		||||
        server = ServerClass(addr, HandlerClass)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1041,7 +1041,7 @@ def _main(args=None):
 | 
			
		|||
            parser.error(f"Failed to read TLS password file: {e}")
 | 
			
		||||
 | 
			
		||||
    # ensure dual-stack is not disabled; ref #38907
 | 
			
		||||
    class DualStackServer(ThreadingHTTPServer):
 | 
			
		||||
    class DualStackServerMixin:
 | 
			
		||||
 | 
			
		||||
        def server_bind(self):
 | 
			
		||||
            # suppress exception when protocol is IPv4
 | 
			
		||||
| 
						 | 
				
			
			@ -1054,9 +1054,16 @@ def finish_request(self, request, client_address):
 | 
			
		|||
            self.RequestHandlerClass(request, client_address, self,
 | 
			
		||||
                                     directory=args.directory)
 | 
			
		||||
 | 
			
		||||
    class HTTPDualStackServer(DualStackServerMixin, ThreadingHTTPServer):
 | 
			
		||||
        pass
 | 
			
		||||
    class HTTPSDualStackServer(DualStackServerMixin, ThreadingHTTPSServer):
 | 
			
		||||
        pass
 | 
			
		||||
 | 
			
		||||
    ServerClass = HTTPSDualStackServer if args.tls_cert else HTTPDualStackServer
 | 
			
		||||
 | 
			
		||||
    test(
 | 
			
		||||
        HandlerClass=SimpleHTTPRequestHandler,
 | 
			
		||||
        ServerClass=DualStackServer,
 | 
			
		||||
        ServerClass=ServerClass,
 | 
			
		||||
        port=args.port,
 | 
			
		||||
        bind=args.bind,
 | 
			
		||||
        protocol=args.protocol,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue