|
Lines 1-25
Link Here
|
| 1 |
--- evhtp.c.orig 2015-02-24 07:55:55 UTC |
1 |
### Description: Commit 67ed0bc caused ports to break, this |
|
|
2 |
### patch will revert the commits until a proper fix is created. |
| 3 |
### Issue ID: https://github.com/ellzey/libevhtp/issues/201 |
| 4 |
### https://github.com/ellzey/libevhtp/commit/67ed0bce433655dfeab65b797279dd167b394feb |
| 5 |
|
| 6 |
--- evhtp.c.orig 2015-11-02 23:01:53 UTC |
| 2 |
+++ evhtp.c |
7 |
+++ evhtp.c |
| 3 |
@@ -7,6 +7,7 @@ |
8 |
@@ -1662,7 +1662,22 @@ _evhtp_create_reply(evhtp_request_t * re |
| 4 |
#include <strings.h> |
9 |
evhtp_headers_add_header(request->headers_out, |
| 5 |
#include <inttypes.h> |
10 |
evhtp_header_new("Content-Length", out_buf, 0, 1)); |
| 6 |
#ifndef WIN32 |
11 |
} |
| 7 |
+#include <sys/types.h> |
12 |
- } |
| 8 |
#include <sys/socket.h> |
13 |
+ if (!content_type) { |
| 9 |
#include <netinet/in.h> |
14 |
+ evhtp_headers_add_header(request->headers_out, |
| 10 |
#include <netinet/tcp.h> |
15 |
+ evhtp_header_new("Content-Type", "text/plain", 0, 0)); |
| 11 |
@@ -3170,7 +3171,14 @@ evhtp_bind_sockaddr(evhtp_t * htp, struc |
16 |
+ } |
|
|
17 |
+ } else { |
| 18 |
+ if (!evhtp_header_find(request->headers_out, "Content-Length")) { |
| 19 |
+ const char * chunked = evhtp_header_find(request->headers_out, |
| 20 |
+ "transfer-encoding"); |
| 21 |
+ |
| 22 |
+ if (!chunked || !strstr(chunked, "chunked")) { |
| 23 |
+ evhtp_headers_add_header(request->headers_out, |
| 24 |
+ evhtp_header_new("Content-Length", "0", 0, 0)); |
| 25 |
+ } |
| 26 |
+ } |
| 27 |
+ } |
| 28 |
+ |
| 29 |
check_proto: |
| 30 |
/* add the proper keep-alive type headers based on http version */ |
| 31 |
switch (request->proto) { |
| 32 |
@@ -1697,11 +1712,6 @@ check_proto: |
| 33 |
} /* switch */ |
| 12 |
|
34 |
|
| 13 |
sock = evconnlistener_get_fd(htp->server); |
|
|
| 14 |
|
35 |
|
| 15 |
+#ifdef TCP_DEFER_ACCEPT |
36 |
- if (!content_type) { |
| 16 |
setsockopt(sock, IPPROTO_TCP, TCP_DEFER_ACCEPT, &one, (ev_socklen_t)sizeof(one)); |
37 |
- evhtp_headers_add_header(request->headers_out, |
| 17 |
+#elif SO_ACCEPTFILTER |
38 |
- evhtp_header_new("Content-Type", "text/plain", 0, 0)); |
| 18 |
+ struct accept_filter_arg afa; |
39 |
- } |
| 19 |
+ bzero(&afa, sizeof(afa)); |
40 |
- |
| 20 |
+ strcpy(afa.af_name, "httpready"); |
41 |
/* attempt to add the status line into a temporary buffer and then use |
| 21 |
+ setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof(afa)); |
42 |
* evbuffer_add(). Using plain old snprintf() will be faster than |
| 22 |
+#endif |
43 |
* evbuffer_add_printf(). If the snprintf() fails, which it rarely should, |
| 23 |
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, &one, (ev_socklen_t)sizeof(one)); |
44 |
@@ -3094,10 +3104,8 @@ evhtp_send_reply_chunk_start(evhtp_reque |
| 24 |
} |
45 |
*/ |
| 25 |
#endif |
46 |
evhtp_kv_rm_and_free(request->headers_out, content_len); |
|
|
47 |
|
| 48 |
-#if 0 |
| 49 |
evhtp_headers_add_header(request->headers_out, |
| 50 |
evhtp_header_new("Content-Length", "0", 0, 0)); |
| 51 |
-#endif |
| 52 |
|
| 53 |
request->chunked = 1; |
| 54 |
break; |
| 55 |
@@ -3955,21 +3963,11 @@ evhtp_request_set_bev(evhtp_request_t * |
| 56 |
evhtp_connection_set_bev(request->conn, bev); |
| 57 |
} |
| 58 |
|
| 59 |
-void |
| 60 |
-evhtp_request_set_keepalive(evhtp_request_t * request, int val) { |
| 61 |
- request->keepalive = (val > 0) ? 1 : 0; |
| 62 |
-} |
| 63 |
- |
| 64 |
evhtp_connection_t * |
| 65 |
evhtp_request_get_connection(evhtp_request_t * request) { |
| 66 |
return request->conn; |
| 67 |
} |
| 68 |
|
| 69 |
-evhtp_proto |
| 70 |
-evhtp_request_get_proto(evhtp_request_t * request) { |
| 71 |
- return request->proto; |
| 72 |
-} |
| 73 |
- |
| 74 |
inline void |
| 75 |
evhtp_connection_set_timeouts(evhtp_connection_t * c, |
| 76 |
const struct timeval * rtimeo, |
| 77 |
@@ -4378,4 +4376,4 @@ evhtp_make_request(evhtp_connection_t * |
| 78 |
unsigned int |
| 79 |
evhtp_request_status(evhtp_request_t * r) { |
| 80 |
return htparser_get_status(r->conn->parser); |
| 81 |
-} |
| 82 |
\ No newline at end of file |
| 83 |
+} |