--- libmicrohttpd-r28483/src/microhttpd/connection.c.orig 2013-08-10 15:35:17.767809700 +0000 +++ libmicrohttpd-r28483/src/microhttpd/connection.c 2013-08-10 15:32:55.391730300 +0000 @@ -2690,6 +2690,17 @@ /* response was queued "early", refuse to read body / footers or further requests! */ +#ifdef WINDOWS + /* do empty the recv buffer before shutting down, + * otherwise buggy winsock won't allow us to send the response! + */ + unsigned long to_read; + if (0 == ioctlsocket (connection->socket_fd, FIONREAD, &to_read)) + { + char throwaway[to_read]; + recv (connection->socket_fd, throwaway, to_read, 0); + } +#endif if (0 == (connection->daemon->options & MHD_USE_EPOLL_TURBO)) (void) SHUTDOWN (connection->socket_fd, SHUT_RD); connection->read_closed = MHD_YES;