Skip to content

Commit a3256fd

Browse files
committed
gh-13056: Allow unspecified response_headers in HTTPServer.
This fixes the breakage to HttpServer as used by wsgiref.
1 parent 1838da7 commit a3256fd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Lib/http/server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class HTTPServer(socketserver.TCPServer):
118118
allow_reuse_port = True
119119

120120
def __init__(self, *args, response_headers=None, **kwargs):
121-
self.response_headers = response_headers if response_headers is not None else {}
121+
self.response_headers = response_headers
122122
super().__init__(*args, **kwargs)
123123

124124
def server_bind(self):
@@ -131,7 +131,10 @@ def server_bind(self):
131131
def finish_request(self, request, client_address):
132132
"""Finish one request by instantiating RequestHandlerClass."""
133133
args = (request, client_address, self)
134-
kwargs = dict(response_headers=self.response_headers) if self.response_headers else dict()
134+
kwargs = {}
135+
response_headers = getattr(self, 'response_headers', None)
136+
if response_headers:
137+
kwargs['response_headers'] = self.response_headers
135138
self.RequestHandlerClass(*args, **kwargs)
136139

137140
class ThreadingHTTPServer(socketserver.ThreadingMixIn, HTTPServer):

0 commit comments

Comments
 (0)