Karlson2k / libmicrohttpd

GNU libmicrohttpd repository unofficial mirror on GitHub
https://www.gnu.org/software/libmicrohttpd/
Other
101 stars 29 forks source link

libmicrohttpd 0.9.76 does not correctly deal with HTTP 1.0 requests? #22

Closed MrdUkk closed 8 months ago

MrdUkk commented 1 year ago

hello!

i got something strange with http procotol versions and connection header. client send: SOURCE /something HTTP/1.0 Authorization: Basic blablabla== Host: localhost Content-type: audio/mpeg User-agent: bla bla bla

libmicrohttpd was answered to client with this: response = MHD_create_response_from_buffer(strlen (EMPTY_PAGE), (void *) EMPTY_PAGE, MHD_RESPMEM_PERSISTENT); ret = MHD_add_response_header(response, MHD_HTTP_HEADER_CONNECTION, "keep-alive"); ret = MHD_queue_response (connection, MHD_HTTP_OK, response); MHD_destroy_response (response);

and on the wire sniffer see: HTTP/1.1 200 OK Connection: close Content-length: 2

and immediately libmicrohttpd closes connection.

i expect server response should follow http protocol version that client asked for. and im asking libmicrohttp explicitly dont close this connection and keep it alive.

Karlson2k commented 8 months ago

I doesn't look like something is wrong here. The response is two bytes long (most probably not included in sniffer results). As connection is HTTP/1.0 and the client does not requested keep-alive, the server must close connection as soon as full response sent.

If you see that response body is not being send, use response with some visible characters (like "ab") and provide the sniffer results.

The MHD testsuite includes number of tests with HTTP/1.0.