Christian Grothoff 18 年 前
コミット
2d797e7b5e

+ 5 - 0
AUTHORS

@@ -1,2 +1,7 @@
+Primary developer:
 Christian Grothoff <[email protected]>
+
+Code contributions also came from:
 Chris GauthierDickey <[email protected]>
+Daniel Pittman 
+Nils Durner <[email protected]>

+ 0 - 1
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:
 =========

+ 21 - 13
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 <[email protected]> and Chris GauthierDickey <[email protected]>.  
+.SH "REPORTING BUGS"
+Report bugs by using mantis <https://gnunet.org/mantis/>.
 
-.SH AVAILABILITY
+.SH "AUTHORS"
+libmicrohttpd was originally designed by Christian Grothoff <[email protected]> and Chris GauthierDickey <[email protected]>.  The implementation was done by Daniel Pittman and Christian Grothoff.
+
+.SH "AVAILABILITY"
 You can obtain the latest version from http://gnunet.org/libmicrohttpd/.

+ 35 - 4
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;

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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

+ 1 - 1
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