libmicrohttpd

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

commit 74cb555978b85abb46e8bb17eb222946da2585ad
parent 51925ec4da4abc946a9d543b1f95eab173dfcc35
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue,  3 Mar 2009 06:53:03 +0000

64-bit and unknown response size fix

Diffstat:
MAUTHORS | 1+
MChangeLog | 5+++++
Msrc/daemon/connection.c | 12++++++------
Msrc/include/microhttpd.h | 9+++++++--
4 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -16,6 +16,7 @@ Peter Ross <pross@xvid.org> RuXu W <wrxzzj@gmail.com> Matthew Moore Colin Caughie <c.caughie@indigovision.com> +David Carvalho <andaris@gmail.com> Documentation contributions also came from: Marco Maggi <marco.maggi-ipsu@poste.it> diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +Mon Mar 2 23:44:08 MST 2009 + Fixd problem with 64-bit upload and download sizes and + "-1" being used to indicate "unknown" by introducing + new 64-bit constant "MHD_SIZE_UNKNOWN". -CG/DC + Wed Feb 18 08:13:56 MST 2009 Added missing #include for build on arm-linux-uclibc. -CG/CC diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -241,7 +241,7 @@ MHD_queue_response (struct MHD_Connection *connection, have already sent the full message body */ connection->response_write_position = response->total_size; } - if ((response->total_size == -1) && + if ((response->total_size == MHD_SIZE_UNKNOWN) && (0 == strcasecmp (connection->version, MHD_HTTP_VERSION_1_1))) connection->have_chunked_response = MHD_YES; else @@ -443,7 +443,7 @@ add_extra_headers (struct MHD_Connection *connection) char buf[128]; connection->have_chunked_upload = MHD_NO; - if (connection->response->total_size == -1) + if (connection->response->total_size == MHD_SIZE_UNKNOWN) { have = MHD_get_response_header (connection->response, MHD_HTTP_HEADER_CONNECTION); @@ -1110,7 +1110,7 @@ call_connection_handler (struct MHD_Connection *connection) { instant_retry = MHD_NO; if ((connection->have_chunked_upload == MHD_YES) && - (connection->remaining_upload_size == -1)) + (connection->remaining_upload_size == MHD_SIZE_UNKNOWN)) { if ((connection->current_chunk_offset == connection->current_chunk_size) @@ -1242,7 +1242,7 @@ call_connection_handler (struct MHD_Connection *connection) /* dh left "processed" bytes in buffer for next time... */ buffer_head += used; available -= used; - if (connection->remaining_upload_size != -1) + if (connection->remaining_upload_size != MHD_SIZE_UNKNOWN) connection->remaining_upload_size -= used; } while (instant_retry == MHD_YES); @@ -1516,7 +1516,7 @@ parse_connection_headers (struct MHD_Connection *connection) } else { - connection->remaining_upload_size = -1; /* unknown size */ + connection->remaining_upload_size = MHD_SIZE_UNKNOWN; if (0 == strcasecmp (MHD_lookup_connection_value (connection, MHD_HEADER_KIND, @@ -1887,7 +1887,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) continue; } if ((connection->remaining_upload_size == 0) || - ((connection->remaining_upload_size == -1) && + ((connection->remaining_upload_size == MHD_SIZE_UNKNOWN) && (connection->read_buffer_offset == 0) && (MHD_YES == connection->read_closed))) { diff --git a/src/include/microhttpd.h b/src/include/microhttpd.h @@ -81,7 +81,7 @@ extern "C" /** * Current version of the library. */ -#define MHD_VERSION 0x00040001 +#define MHD_VERSION 0x00040002 /** * MHD-internal return codes. @@ -91,6 +91,11 @@ extern "C" #define MHD_NO 0 /** + * Constant used to indicate unknown size. + */ +#define MHD_SIZE_UNKNOWN ((uint64_t) -1LL) + +/** * HTTP response codes. */ #define MHD_HTTP_CONTINUE 100 @@ -959,7 +964,7 @@ MHD_queue_response (struct MHD_Connection *connection, * Create a response object. The response object can be extended with * header information and then be used any number of times. * - * @param size size of the data portion of the response, -1 for unknown + * @param size size of the data portion of the response, MHD_SIZE_UNKNOW for unknown * @param block_size preferred block size for querying crc (advisory only, * MHD may still call crc using smaller chunks); this * is essentially the buffer size used for IO, clients