libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 9e2d653d53c200fbf80e131fb5a53efa0f5fec7c
parent 5946959f76fda2b28487d02d4329bc32f6ec7663
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 12 Jul 2013 08:53:09 +0000

-update readiness state immediately after response is queued, to avoid going through another 'idle' event loop

Diffstat:
Msrc/microhttpd/connection.c | 87++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 44 insertions(+), 43 deletions(-)

diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -228,49 +228,6 @@ MHD_lookup_connection_value (struct MHD_Connection *connection, /** - * Queue a response to be transmitted to the client (as soon as - * possible but after MHD_AccessHandlerCallback returns). - * - * @param connection the connection identifying the client - * @param status_code HTTP status code (i.e. 200 for OK) - * @param response response to transmit - * @return MHD_NO on error (i.e. reply already sent), - * MHD_YES on success or if message has been queued - */ -int -MHD_queue_response (struct MHD_Connection *connection, - unsigned int status_code, struct MHD_Response *response) -{ - if ( (NULL == connection) || - (NULL == response) || - (NULL != connection->response) || - ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && - (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) - return MHD_NO; - MHD_increment_response_rc (response); - connection->response = response; - connection->responseCode = status_code; - if ( (NULL != connection->method) && - (0 == strcasecmp (connection->method, MHD_HTTP_METHOD_HEAD)) ) - { - /* if this is a "HEAD" request, pretend that we - have already sent the full message body */ - connection->response_write_position = response->total_size; - } - if (MHD_CONNECTION_HEADERS_PROCESSED == connection->state) - { - /* response was queued "early", - refuse to read body / footers or further - requests! */ - (void) SHUTDOWN (connection->socket_fd, SHUT_RD); - connection->read_closed = MHD_YES; - connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; - } - return MHD_YES; -} - - -/** * Do we (still) need to send a 100 continue * message for this connection? * @@ -2595,4 +2552,48 @@ MHD_set_connection_option (struct MHD_Connection *connection, } +/** + * Queue a response to be transmitted to the client (as soon as + * possible but after MHD_AccessHandlerCallback returns). + * + * @param connection the connection identifying the client + * @param status_code HTTP status code (i.e. 200 for OK) + * @param response response to transmit + * @return MHD_NO on error (i.e. reply already sent), + * MHD_YES on success or if message has been queued + */ +int +MHD_queue_response (struct MHD_Connection *connection, + unsigned int status_code, struct MHD_Response *response) +{ + if ( (NULL == connection) || + (NULL == response) || + (NULL != connection->response) || + ( (MHD_CONNECTION_HEADERS_PROCESSED != connection->state) && + (MHD_CONNECTION_FOOTERS_RECEIVED != connection->state) ) ) + return MHD_NO; + MHD_increment_response_rc (response); + connection->response = response; + connection->responseCode = status_code; + if ( (NULL != connection->method) && + (0 == strcasecmp (connection->method, MHD_HTTP_METHOD_HEAD)) ) + { + /* if this is a "HEAD" request, pretend that we + have already sent the full message body */ + connection->response_write_position = response->total_size; + } + if (MHD_CONNECTION_HEADERS_PROCESSED == connection->state) + { + /* response was queued "early", + refuse to read body / footers or further + requests! */ + (void) SHUTDOWN (connection->socket_fd, SHUT_RD); + connection->read_closed = MHD_YES; + connection->state = MHD_CONNECTION_FOOTERS_RECEIVED; + } + MHD_connection_update_event_loop_info (connection); + return MHD_YES; +} + + /* end of connection.c */