Index: configure.ac =================================================================== --- configure.ac (revision 7846) +++ configure.ac (working copy) @@ -136,7 +136,7 @@ AC_CHECK_HEADERS([fcntl.h math.h errno.h limits.h stdio.h locale.h sys/stat.h sys/types.h pthread.h],,AC_MSG_ERROR([Compiling libmicrohttpd requires standard UNIX headers files])) # Check for optional headers -AC_CHECK_HEADERS([sys/select.h sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h time.h sys/socket.h sys/mman.h arpa/inet.h]) +AC_CHECK_HEADERS([sys/select.h sys/types.h sys/time.h sys/msg.h netdb.h netinet/in.h netinet/tcp.h time.h sys/socket.h sys/mman.h arpa/inet.h]) # IPv6 AC_MSG_CHECKING(for IPv6) @@ -161,6 +161,8 @@ ) AC_MSG_RESULT($have_inet6) +# TCP_CORK +AC_CHECK_DECL([TCP_CORK], [], [], [[#include ]]) # libcurl (required for testing) SAVE_LIBS=$LIBS Index: src/daemon/connection.c =================================================================== --- src/daemon/connection.c (revision 7846) +++ src/daemon/connection.c (working copy) @@ -1921,6 +1921,14 @@ continue; } connection->state = MHD_CONNECTION_HEADERS_SENDING; + +#if HAVE_TCP_CORK + /* starting header send, set TCP cork */ + { + const int val = 1; + setsockopt(connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, sizeof(val)); + } +#endif break; case MHD_CONNECTION_HEADERS_SENDING: /* no default action */ @@ -1976,6 +1984,13 @@ /* no default action */ break; case MHD_CONNECTION_FOOTERS_SENT: +#if HAVE_TCP_CORK + /* done sending, uncork */ + { + const int val = 0; + setsockopt(connection->socket_fd, IPPROTO_TCP, TCP_CORK, &val, sizeof(val)); + } +#endif MHD_destroy_response (connection->response); if (connection->daemon->notify_completed != NULL) connection->daemon->notify_completed (connection->