Open kwsy opened 1 month ago
Why, even if \r\n\r\n is not found, is the message header considered to have ended?
Because on reading the request (and PROXY
) line, its trailing \r\n
was discarded from buf
. Thus done
distinguishes a) expecting two consecutive \r\n
marking the last header and b) just expecting a single \r\n
at the start to signal a HTTP/1.0 request with zero headers.
The code could be refactored to remove most of the complexity and be more efficient for invalid/oversize/partial input - but I do not see a logical flaw. If you do, please show the request that you consider incorrectly parsed.
`def parse(self, unreader): buf = io.BytesIO() self.get_data(unreader, buf, stop=True)
`
parse is the method of Request class , It reads the message header part of the HTTP request. There is always \r\n\r\n between the message header and the message body. However, the method checks whether the first two bytes of data are \r\n. This is strange. Isn't the end marker of the message header only \r\n\r\n? Why, even if \r\n\r\n is not found, is the message header considered to have ended when data starts with \r\n? Is there any basis for doing this?