libmicrohttpd

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

commit 2d797e7b5e22d6502226e6cd9cf8eb2fc0a2454f
parent 268f93a9686c899d954c1892ec62aefcaa6fc4a3
Author: Christian Grothoff <christian@grothoff.org>
Date:   Wed,  8 Aug 2007 20:48:41 +0000

fixing 1261

Diffstat:
MAUTHORS | 5+++++
MREADME | 1-
Mdoc/libmicrohttpd.3 | 34+++++++++++++++++++++-------------
Msrc/daemon/connection.c | 39+++++++++++++++++++++++++++++++++++----
Msrc/daemon/connection.h | 2+-
Msrc/daemon/daemon.c | 2+-
Msrc/daemon/internal.c | 2+-
Msrc/daemon/internal.h | 2+-
Msrc/daemon/memorypool.c | 2+-
Msrc/daemon/memorypool.h | 2+-
Msrc/daemon/response.c | 2+-
Msrc/daemon/response.h | 2+-
12 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/AUTHORS b/AUTHORS @@ -1,2 +1,7 @@ +Primary developer: Christian Grothoff <christian@grothoff.org> + +Code contributions also came from: Chris GauthierDickey <chrisg@cs.du.edu> +Daniel Pittman +Nils Durner <durner@gnunet.org> diff --git a/README b/README @@ -16,7 +16,6 @@ For http/1.1-compliance: connection.c: - support chunked requests from clients (#1260, ARCH, TEST) - send proper error code back if client forgot the "Host" header (#1264, TRIV) -- automatically add MHD_HTTP_HEADER_DATE if client "forgot" to add one (#1261, TRIV) For POST: ========= diff --git a/doc/libmicrohttpd.3 b/doc/libmicrohttpd.3 @@ -1,28 +1,36 @@ -.TH LIBMICROHTTPD 3 "Jan 12, 2007" -.SH NAME -libmicrohttpd \- description 0.0.0 -.SH SYNOPSIS +.TH LIBMICROHTTPD "3" "08 Aug 2007" "libmicrohttpd" +.SH "NAME" +libmicrohttpd \- library for embedding HTTP servers +.SH "SYNOPSIS" \fB#include <microhttpd.h> -Insert API here. +\fPInsert API here. -.SH DESCRIPTION +.SH "DESCRIPTION" .P Insert API description here. .P .SH "SEE ALSO" -fixme(1) +\fBcurl\fP(1), \fBlibcurl\fP(3) -.SH LEGAL NOTICE +.SH "LEGAL NOTICE" libmicrohttpd is released under the GPL. -.SH BUGS -None, of course. +.SH "FILES" +.TP +microhttpd.h +libmicrohttpd include file +.TP +libmicrohttpd.so +libmicrohttpd library -.SH AUTHORS -libmicrohttpd was originally designed by Christian Grothoff <christian@grothoff.org> and Chris GauthierDickey <chrisg@cs.du.edu>. +.SH "REPORTING BUGS" +Report bugs by using mantis <https://gnunet.org/mantis/>. -.SH AVAILABILITY +.SH "AUTHORS" +libmicrohttpd was originally designed by Christian Grothoff <christian@grothoff.org> and Chris GauthierDickey <chrisg@cs.du.edu>. The implementation was done by Daniel Pittman and Christian Grothoff. + +.SH "AVAILABILITY" You can obtain the latest version from http://gnunet.org/libmicrohttpd/. diff --git a/src/daemon/connection.c b/src/daemon/connection.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -880,10 +880,10 @@ MHD_add_extra_headers(struct MHD_Connection * connection) { if (connection->response->total_size == -1) { have = MHD_get_response_header(connection->response, - "Connection"); + MHD_HTTP_HEADER_CONNECTION); if (have == NULL) MHD_add_response_header(connection->response, - "Connection", + MHD_HTTP_HEADER_CONNECTION, "close"); } else if (NULL == MHD_get_response_header(connection->response, MHD_HTTP_HEADER_CONTENT_LENGTH)) { @@ -894,7 +894,28 @@ MHD_add_extra_headers(struct MHD_Connection * connection) { MHD_add_response_header(connection->response, MHD_HTTP_HEADER_CONTENT_LENGTH, buf); - } + } +} + +static void get_date_string(char * date, + unsigned int max) { + static const char * days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; + static const char * mons[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + struct tm now; + time_t t; + + time(&t); + gmtime_r(&t, &now); + snprintf(date, + max-1, + "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n", + days[now.tm_wday % 7], + now.tm_mday, + mons[now.tm_mon % 12], + now.tm_year, + now.tm_hour, + now.tm_min, + now.tm_sec); } /** @@ -908,6 +929,7 @@ MHD_build_header_response(struct MHD_Connection * connection) { size_t off; struct MHD_HTTP_Header * pos; char code[32]; + char date[128]; char * data; MHD_add_extra_headers(connection); @@ -923,6 +945,12 @@ MHD_build_header_response(struct MHD_Connection * connection) { size += strlen(pos->header) + strlen(pos->value) + 4; /* colon, space, linefeeds */ pos = pos->next; } + if (NULL == MHD_get_response_header(connection->response, + MHD_HTTP_HEADER_DATE)) + get_date_string(date, sizeof(date)); + else + date[0] = '\0'; + size += strlen(date); /* produce data */ data = MHD_pool_allocate(connection->pool, size + 1, @@ -944,6 +972,9 @@ MHD_build_header_response(struct MHD_Connection * connection) { off += strlen(pos->header) + strlen(pos->value) + 4; pos = pos->next; } + strcpy(&data[off], + date); + off += strlen(date); sprintf(&data[off], "\r\n"); off += 2; diff --git a/src/daemon/connection.h b/src/daemon/connection.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/internal.c b/src/daemon/internal.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/internal.h b/src/daemon/internal.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/memorypool.h b/src/daemon/memorypool.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/response.c b/src/daemon/response.c @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published diff --git a/src/daemon/response.h b/src/daemon/response.h @@ -1,6 +1,6 @@ /* This file is part of libmicrohttpd - (C) 2007 Daniel Pittman + (C) 2007 Daniel Pittman and Christian Grothoff libmicrohttpd is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published