File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -72,20 +72,20 @@ def _construct_response_bytes( # pylint: disable=too-many-arguments
72
72
) -> bytes :
73
73
"""Constructs the response bytes from the given parameters."""
74
74
75
- response = f"{ http_version } { status .code } { status .text } \r \n "
75
+ response_message_header = f"{ http_version } { status .code } { status .text } \r \n "
76
+ encoded_response_message_body = body .encode ("utf-8" )
76
77
77
78
headers .setdefault ("Content-Type" , content_type )
78
79
headers .setdefault (
79
- "Content-Length" , content_length or len (body . encode ( "utf-8" ) )
80
+ "Content-Length" , content_length or len (encoded_response_message_body )
80
81
)
81
82
headers .setdefault ("Connection" , "close" )
82
83
83
84
for header , value in headers .items ():
84
- response += f"{ header } : { value } \r \n "
85
+ response_message_header += f"{ header } : { value } \r \n "
86
+ response_message_header += "\r \n "
85
87
86
- response += f"\r \n { body } "
87
-
88
- return response .encode ("utf-8" )
88
+ return response_message_header .encode ("utf-8" ) + encoded_response_message_body
89
89
90
90
def send (self , conn : Union ["SocketPool.Socket" , "socket.socket" ]) -> None :
91
91
"""
You can’t perform that action at this time.
0 commit comments