@@ -809,7 +809,7 @@ def parse_request(self):
809
809
elif self .method == b'CONNECT' :
810
810
# TODO: cover this branch with tests
811
811
if not self .proxy_mode :
812
- self .simple_response (' 405 Method Not Allowed' )
812
+ self .simple_response (405 )
813
813
return False
814
814
815
815
# `urlsplit()` above parses "example.com:3128" as path part of URI.
@@ -833,7 +833,7 @@ def parse_request(self):
833
833
)
834
834
if invalid_path :
835
835
self .simple_response (
836
- ' 400 Bad Request' ,
836
+ 400 ,
837
837
'Invalid path in Request-URI: request-'
838
838
'target must match authority-form.' ,
839
839
)
@@ -852,7 +852,7 @@ def parse_request(self):
852
852
# (absolute form)
853
853
"""Absolute URI is only allowed within proxies."""
854
854
self .simple_response (
855
- ' 400 Bad Request' ,
855
+ 400 ,
856
856
'Absolute URI not allowed if server is not a proxy.' ,
857
857
)
858
858
return False
@@ -871,7 +871,7 @@ def parse_request(self):
871
871
'origin-form which starts with absolute-path (URI '
872
872
'starting with a slash "/").'
873
873
)
874
- self .simple_response (' 400 Bad Request' , resp )
874
+ self .simple_response (400 , resp )
875
875
return False
876
876
try :
877
877
# TODO: Figure out whether exception can really happen here.
@@ -962,8 +962,10 @@ def respond(self):
962
962
# close connection if reuse unavailable
963
963
self .close_connection = True
964
964
965
- def simple_response (self , status , msg = '' ):
965
+ def simple_response (self , status , msg = None ):
966
966
"""Write a simple response back to the client."""
967
+ if msg is None :
968
+ msg = ''
967
969
status = str (status )
968
970
headers = [
969
971
('Content-Type' , 'text/plain' )
0 commit comments