Greetings. I use libmicrohttpd in my project and I found one bug in a very specific situation with chunked messages.
The scheme I use is keep-alive connection for transferring some files (chunked content, HTTP/1.1 pipelining). When transfer is over, connection is closed by client request. I create responses with MHD_create_response_from_callback and the HTTP header "Transfer-Encoding: chunked" is automatically added to packet headers. But when the transfer is over and the last file requested, client sends "Connection: close". Theoretically, by HTTP standard, the server should process the request and then close the socket. And it does so, it sends the chunked data and closes the connection. But in the response to the last request it loses the "Transfer-Encoding: chunked" header and the client fails to accept the wrong formatted HTTP packet. If I manually add "Transfer-Encoding: chunked" to the last HTTP response, it works fine. I think the problem hides in this code piece: file src/microhttpd/connection.c, line 1376, in function have_chunked_upload: ----------------------------------------------------------------- if ( (MHD_NO != keepalive_possible (connection)) && (MHD_str_equal_caseless_ (MHD_HTTP_VERSION_1_1, connection->version) ) ) { if (NULL == have_encoding) { must_add_chunked_encoding = true; connection->have_chunked_upload = true; } ... ----------------------------------------------------------------- The connection is marked as non keep-alive at the moment after "Connection: close" and the content is still chunked. But the flag is not set and then the error occurs. Sincerely, Yana A. Kireyonok aka Iron Bug