diff options
author | Niels Provos <provos@gmail.com> | 2006-12-02 21:29:54 +0000 |
---|---|---|
committer | Niels Provos <provos@gmail.com> | 2006-12-02 21:29:54 +0000 |
commit | 62ee1c68a54bdc744cc2dac69cdeaa5585c93261 (patch) | |
tree | 535e32e910580bafb27b71899741ccc323886a00 | |
parent | 9f15d02d4d9061404893c27c7a29ddaf704cc729 (diff) | |
download | libevent-release-1.2a.tar.gz |
merge from trunk:release-1.2a
- CLOCK_MONOTONIC fixes
- http content-length fixes
svn:r292
-rw-r--r-- | evdns.c | 6 | ||||
-rw-r--r-- | event.c | 6 | ||||
-rw-r--r-- | http.c | 31 |
3 files changed, 28 insertions, 15 deletions
@@ -799,7 +799,11 @@ transaction_id_pick(void) { #ifdef DNS_USE_CPU_CLOCK_FOR_ID struct timespec ts; u16 trans_id; - if (clock_gettime(CLOCK_MONOTONIC, &ts)) +#ifdef CLOCK_MONOTONIC + if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) +#else + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) +#endif event_err(1, "clock_gettime"); trans_id = ts.tv_nsec & 0xffff; #endif @@ -149,8 +149,12 @@ gettime(struct timeval *tp) { #ifdef HAVE_CLOCK_GETTIME struct timespec ts; - + +#ifdef HAVE_CLOCK_MONOTONIC if (clock_gettime(CLOCK_MONOTONIC, &ts) == -1) +#else + if (clock_gettime(CLOCK_REALTIME, &ts) == -1) +#endif return (-1); tp->tv_sec = ts.tv_sec; tp->tv_usec = ts.tv_nsec / 1000; @@ -302,21 +302,26 @@ evhttp_make_header_response(struct evhttp_connection *evcon, req->response_code_line); evbuffer_add(evcon->output_buffer, line, strlen(line)); - /* Potentially add headers */ - if (evhttp_find_header(req->output_headers, "Content-Type") == NULL) { + /* Potentially add headers for unidentified content. */ + if (EVBUFFER_LENGTH(req->output_buffer) && + evhttp_find_header(req->output_headers, "Content-Type") == NULL) { evhttp_add_header(req->output_headers, "Content-Type", "text/html; charset=ISO-8859-1"); - } - - /* - * we need to add the content length if the user did not give it, - * this is required for persistent connections to work. - */ - if (evhttp_find_header(req->output_headers, "Content-Length") == NULL){ - static char len[12]; - snprintf(len, sizeof(len), "%ld", - (long)EVBUFFER_LENGTH(req->output_buffer)); - evhttp_add_header(req->output_headers, "Content-Length", len); + /* + * we need to add the content length if the user did + * not give it, this is required for persistent + * connections to work. + */ + if (evhttp_find_header(req->output_headers, + "Transfer-Encoding") == NULL && + evhttp_find_header(req->output_headers, + "Content-Length") == NULL) { + static char len[12]; + snprintf(len, sizeof(len), "%ld", + (long)EVBUFFER_LENGTH(req->output_buffer)); + evhttp_add_header(req->output_headers, + "Content-Length", len); + } } /* if the request asked for a close, we send a close, too */ |