mirror of
https://github.com/python/cpython.git
synced 2025-09-18 14:40:43 +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,7 +980,7 @@ def test(HandlerClass=BaseHTTPRequestHandler,
|
|||
HandlerClass.protocol_version = protocol
|
||||
|
||||
if tls_cert:
|
||||
server = ThreadingHTTPSServer(addr, HandlerClass, certfile=tls_cert,
|
||||
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 _main(args=None):
|
|||
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,
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
:mod:`http.server`: Fix IPv6 address binding and
|
||||
:option:`--directory <http.server --directory>` handling when using HTTPS.
|
Loading…
Add table
Add a link
Reference in a new issue