aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-08-08 20:48:41 +0000
committerChristian Grothoff <christian@grothoff.org>2007-08-08 20:48:41 +0000
commit2d797e7b5e22d6502226e6cd9cf8eb2fc0a2454f (patch)
tree063338cdffdcc485e077d38a6441320d2dc6e5f7
parent268f93a9686c899d954c1892ec62aefcaa6fc4a3 (diff)
downloadlibmicrohttpd-2d797e7b5e22d6502226e6cd9cf8eb2fc0a2454f.tar.gz
libmicrohttpd-2d797e7b5e22d6502226e6cd9cf8eb2fc0a2454f.zip
fixing 1261
-rw-r--r--AUTHORS5
-rw-r--r--README1
-rw-r--r--doc/libmicrohttpd.334
-rw-r--r--src/daemon/connection.c39
-rw-r--r--src/daemon/connection.h2
-rw-r--r--src/daemon/daemon.c2
-rw-r--r--src/daemon/internal.c2
-rw-r--r--src/daemon/internal.h2
-rw-r--r--src/daemon/memorypool.c2
-rw-r--r--src/daemon/memorypool.h2
-rw-r--r--src/daemon/response.c2
-rw-r--r--src/daemon/response.h2
12 files changed, 69 insertions, 26 deletions
diff --git a/AUTHORS b/AUTHORS
index e01f07ab..2efb4aee 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,2 +1,7 @@
1Primary developer:
1Christian Grothoff <christian@grothoff.org> 2Christian Grothoff <christian@grothoff.org>
3
4Code contributions also came from:
2Chris GauthierDickey <chrisg@cs.du.edu> 5Chris GauthierDickey <chrisg@cs.du.edu>
6Daniel Pittman
7Nils Durner <durner@gnunet.org>
diff --git a/README b/README
index 78a85961..1b2e70bb 100644
--- a/README
+++ b/README
@@ -16,7 +16,6 @@ For http/1.1-compliance:
16connection.c: 16connection.c:
17- support chunked requests from clients (#1260, ARCH, TEST) 17- support chunked requests from clients (#1260, ARCH, TEST)
18- send proper error code back if client forgot the "Host" header (#1264, TRIV) 18- send proper error code back if client forgot the "Host" header (#1264, TRIV)
19- automatically add MHD_HTTP_HEADER_DATE if client "forgot" to add one (#1261, TRIV)
20 19
21For POST: 20For POST:
22========= 21=========
diff --git a/doc/libmicrohttpd.3 b/doc/libmicrohttpd.3
index 72c6a968..4480c93c 100644
--- a/doc/libmicrohttpd.3
+++ b/doc/libmicrohttpd.3
@@ -1,28 +1,36 @@
1.TH LIBMICROHTTPD 3 "Jan 12, 2007" 1.TH LIBMICROHTTPD "3" "08 Aug 2007" "libmicrohttpd"
2.SH NAME 2.SH "NAME"
3libmicrohttpd \- description 0.0.0 3libmicrohttpd \- library for embedding HTTP servers
4.SH SYNOPSIS 4.SH "SYNOPSIS"
5 5
6\fB#include <microhttpd.h> 6\fB#include <microhttpd.h>
7 7
8Insert API here. 8\fPInsert API here.
9 9
10.SH DESCRIPTION 10.SH "DESCRIPTION"
11.P 11.P
12Insert API description here. 12Insert API description here.
13 13
14.P 14.P
15.SH "SEE ALSO" 15.SH "SEE ALSO"
16fixme(1) 16\fBcurl\fP(1), \fBlibcurl\fP(3)
17 17
18.SH LEGAL NOTICE 18.SH "LEGAL NOTICE"
19libmicrohttpd is released under the GPL. 19libmicrohttpd is released under the GPL.
20 20
21.SH BUGS 21.SH "FILES"
22None, of course. 22.TP
23microhttpd.h
24libmicrohttpd include file
25.TP
26libmicrohttpd.so
27libmicrohttpd library
23 28
24.SH AUTHORS 29.SH "REPORTING BUGS"
25libmicrohttpd was originally designed by Christian Grothoff <christian@grothoff.org> and Chris GauthierDickey <chrisg@cs.du.edu>. 30Report bugs by using mantis <https://gnunet.org/mantis/>.
26 31
27.SH AVAILABILITY 32.SH "AUTHORS"
33libmicrohttpd 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.
34
35.SH "AVAILABILITY"
28You can obtain the latest version from http://gnunet.org/libmicrohttpd/. 36You can obtain the latest version from http://gnunet.org/libmicrohttpd/.
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index 5139ae0c..505e4aad 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -880,10 +880,10 @@ MHD_add_extra_headers(struct MHD_Connection * connection) {
880 880
881 if (connection->response->total_size == -1) { 881 if (connection->response->total_size == -1) {
882 have = MHD_get_response_header(connection->response, 882 have = MHD_get_response_header(connection->response,
883 "Connection"); 883 MHD_HTTP_HEADER_CONNECTION);
884 if (have == NULL) 884 if (have == NULL)
885 MHD_add_response_header(connection->response, 885 MHD_add_response_header(connection->response,
886 "Connection", 886 MHD_HTTP_HEADER_CONNECTION,
887 "close"); 887 "close");
888 } else if (NULL == MHD_get_response_header(connection->response, 888 } else if (NULL == MHD_get_response_header(connection->response,
889 MHD_HTTP_HEADER_CONTENT_LENGTH)) { 889 MHD_HTTP_HEADER_CONTENT_LENGTH)) {
@@ -894,7 +894,28 @@ MHD_add_extra_headers(struct MHD_Connection * connection) {
894 MHD_add_response_header(connection->response, 894 MHD_add_response_header(connection->response,
895 MHD_HTTP_HEADER_CONTENT_LENGTH, 895 MHD_HTTP_HEADER_CONTENT_LENGTH,
896 buf); 896 buf);
897 } 897 }
898}
899
900static void get_date_string(char * date,
901 unsigned int max) {
902 static const char * days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
903 static const char * mons[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
904 struct tm now;
905 time_t t;
906
907 time(&t);
908 gmtime_r(&t, &now);
909 snprintf(date,
910 max-1,
911 "Date: %3s, %02u %3s %04u %02u:%02u:%02u GMT\r\n",
912 days[now.tm_wday % 7],
913 now.tm_mday,
914 mons[now.tm_mon % 12],
915 now.tm_year,
916 now.tm_hour,
917 now.tm_min,
918 now.tm_sec);
898} 919}
899 920
900/** 921/**
@@ -908,6 +929,7 @@ MHD_build_header_response(struct MHD_Connection * connection) {
908 size_t off; 929 size_t off;
909 struct MHD_HTTP_Header * pos; 930 struct MHD_HTTP_Header * pos;
910 char code[32]; 931 char code[32];
932 char date[128];
911 char * data; 933 char * data;
912 934
913 MHD_add_extra_headers(connection); 935 MHD_add_extra_headers(connection);
@@ -923,6 +945,12 @@ MHD_build_header_response(struct MHD_Connection * connection) {
923 size += strlen(pos->header) + strlen(pos->value) + 4; /* colon, space, linefeeds */ 945 size += strlen(pos->header) + strlen(pos->value) + 4; /* colon, space, linefeeds */
924 pos = pos->next; 946 pos = pos->next;
925 } 947 }
948 if (NULL == MHD_get_response_header(connection->response,
949 MHD_HTTP_HEADER_DATE))
950 get_date_string(date, sizeof(date));
951 else
952 date[0] = '\0';
953 size += strlen(date);
926 /* produce data */ 954 /* produce data */
927 data = MHD_pool_allocate(connection->pool, 955 data = MHD_pool_allocate(connection->pool,
928 size + 1, 956 size + 1,
@@ -944,6 +972,9 @@ MHD_build_header_response(struct MHD_Connection * connection) {
944 off += strlen(pos->header) + strlen(pos->value) + 4; 972 off += strlen(pos->header) + strlen(pos->value) + 4;
945 pos = pos->next; 973 pos = pos->next;
946 } 974 }
975 strcpy(&data[off],
976 date);
977 off += strlen(date);
947 sprintf(&data[off], 978 sprintf(&data[off],
948 "\r\n"); 979 "\r\n");
949 off += 2; 980 off += 2;
diff --git a/src/daemon/connection.h b/src/daemon/connection.h
index 59b99004..840ae640 100644
--- a/src/daemon/connection.h
+++ b/src/daemon/connection.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c
index 48ec9219..57035fd1 100644
--- a/src/daemon/daemon.c
+++ b/src/daemon/daemon.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/internal.c b/src/daemon/internal.c
index eed1acba..ef67affc 100644
--- a/src/daemon/internal.c
+++ b/src/daemon/internal.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 1c3525f6..57e5ebf1 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/memorypool.c b/src/daemon/memorypool.c
index 5b54cd2e..d8e835e8 100644
--- a/src/daemon/memorypool.c
+++ b/src/daemon/memorypool.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/memorypool.h b/src/daemon/memorypool.h
index c49e0d8e..693b03f6 100644
--- a/src/daemon/memorypool.h
+++ b/src/daemon/memorypool.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/response.c b/src/daemon/response.c
index 4bbe0f36..b816a8a5 100644
--- a/src/daemon/response.c
+++ b/src/daemon/response.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
diff --git a/src/daemon/response.h b/src/daemon/response.h
index c865951f..ab582f00 100644
--- a/src/daemon/response.h
+++ b/src/daemon/response.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 (C) 2007 Daniel Pittman 3 (C) 2007 Daniel Pittman and Christian Grothoff
4 4
5 libmicrohttpd is free software; you can redistribute it and/or modify 5 libmicrohttpd is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published