File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,20 +72,20 @@ def _construct_response_bytes( # pylint: disable=too-many-arguments
7272 ) -> bytes :
7373 """Constructs the response bytes from the given parameters."""
7474
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" )
7677
7778 headers .setdefault ("Content-Type" , content_type )
7879 headers .setdefault (
79- "Content-Length" , content_length or len (body . encode ( "utf-8" ) )
80+ "Content-Length" , content_length or len (encoded_response_message_body )
8081 )
8182 headers .setdefault ("Connection" , "close" )
8283
8384 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 "
8587
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
8989
9090 def send (self , conn : Union ["SocketPool.Socket" , "socket.socket" ]) -> None :
9191 """
You can’t perform that action at this time.
0 commit comments