mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
r14974@catbus: nickm | 2007-09-06 20:59:14 -0400
Changes to http.c: Add a Date header on replies if there is none already set. Also, include time.h unconditionally to be sure that struct tm is declared: every platform has time.h; the conditional should have been for sys/time.h. svn:r412
This commit is contained in:
parent
9c3ac4e444
commit
8d5ef326ba
@ -2,3 +2,4 @@ Changes in current version:
|
|||||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||||
o demote most http warnings to debug messages
|
o demote most http warnings to debug messages
|
||||||
o Fix Solaris compilation; from Magne Mahre
|
o Fix Solaris compilation; from Magne Mahre
|
||||||
|
o Add a "Date" header to HTTP responses, as required by HTTP 1.1.
|
17
http.c
17
http.c
@ -64,9 +64,10 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#endif
|
#endif
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#ifdef HAVE_TIME_H
|
#ifdef HAVE_SYS_TIME_H
|
||||||
#include <time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
@ -351,6 +352,18 @@ evhttp_make_header_response(struct evhttp_connection *evcon,
|
|||||||
|
|
||||||
/* Potentially add headers for unidentified content. */
|
/* Potentially add headers for unidentified content. */
|
||||||
if (EVBUFFER_LENGTH(req->output_buffer)) {
|
if (EVBUFFER_LENGTH(req->output_buffer)) {
|
||||||
|
if (evhttp_find_header(req->output_headers,
|
||||||
|
"Date") == NULL) {
|
||||||
|
char date[50];
|
||||||
|
struct tm cur;
|
||||||
|
time_t t = time(NULL);
|
||||||
|
gmtime_r(&t, &cur);
|
||||||
|
if (strftime(date, sizeof(date),
|
||||||
|
"%a, %d %b %Y %H:%M:%S GMT", &cur) != 0) {
|
||||||
|
evhttp_add_header(req->output_headers, "Date", date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (evhttp_find_header(req->output_headers,
|
if (evhttp_find_header(req->output_headers,
|
||||||
"Content-Type") == NULL) {
|
"Content-Type") == NULL) {
|
||||||
evhttp_add_header(req->output_headers,
|
evhttp_add_header(req->output_headers,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user