Browse files

Merge branch 'release/1.2.3'

  • Loading branch information...
2 parents 6790649 + 78ca62a commit 826a0b238fde731694e364f7780eba1904385c39 Mark Ellzey committed Mar 26, 2013
Showing with 43 additions and 21 deletions.
  1. +1 −1 CMakeLists.txt
  2. +3 −0 ChangeLog
  3. +18 −8 evhtp.c
  4. +20 −11 evhtp.h
  5. +1 −1 examples/test.c
View
2 CMakeLists.txt
@@ -3,7 +3,7 @@ project(reason)
set(PROJECT_MAJOR_VERSION 1)
set(PROJECT_MINOR_VERSION 2)
-set(PROJECT_PATCH_VERSION 2)
+set(PROJECT_PATCH_VERSION 3)
set (PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
View
3 ChangeLog
@@ -1,3 +1,6 @@
+v1.2.3
+ o Added evhtp_disable_100_continue() which informs evhtp to not send a 100 continue response. (1d0eb84 Mark Ellzey)
+
v1.2.1
o Add signal.h as reported by gnehzuil (1ac8706 Mark Ellzey)
o evthr_*set_backlog for SO_RCVBUF sockopts (93f35d9 Mark Ellzey)
View
26 evhtp.c
@@ -1153,14 +1153,19 @@ _evhtp_request_parser_headers(htparser * p) {
return -1;
}
- if (!evhtp_header_find(c->request->headers_in, "Expect")) {
- return 0;
- }
+ if (c->htp->disable_100_cont == 0) {
+ /* only send a 100 continue response if it hasn't been disabled via
+ * evhtp_disable_100_continue.
+ */
+ if (!evhtp_header_find(c->request->headers_in, "Expect")) {
+ return 0;
+ }
- evbuffer_add_printf(bufferevent_get_output(c->bev),
- "HTTP/%d.%d 100 Continue\r\n\r\n",
- htparser_get_major(p),
- htparser_get_minor(p));
+ evbuffer_add_printf(bufferevent_get_output(c->bev),
+ "HTTP/%d.%d 100 Continue\r\n\r\n",
+ htparser_get_major(p),
+ htparser_get_minor(p));
+ }
return 0;
}
@@ -2340,7 +2345,7 @@ evhtp_parse_query(const char * query, size_t len) {
val_idx = 0;
for (i = 0; i < len; i++) {
- ch = query[i];
+ ch = query[i];
if (key_idx >= len || val_idx >= len) {
goto error;
@@ -3458,6 +3463,11 @@ evhtp_set_max_body_size(evhtp_t * htp, uint64_t len) {
htp->max_body_size = len;
}
+void
+evhtp_disable_100_continue(evhtp_t * htp) {
+ htp->disable_100_cont = 1;
+}
+
int
evhtp_add_alias(evhtp_t * evhtp, const char * name) {
evhtp_alias_t * alias;
View
31 evhtp.h
@@ -167,10 +167,10 @@ typedef void (*evhtp_ssl_scache_del)(evhtp_t * htp, unsigned char * sid, int sid
typedef evhtp_ssl_sess_t * (*evhtp_ssl_scache_get)(evhtp_connection_t * connection, unsigned char * sid, int sid_len);
typedef void * (*evhtp_ssl_scache_init)(evhtp_t *);
-#define EVHTP_VERSION "1.2.2"
+#define EVHTP_VERSION "1.2.3"
#define EVHTP_VERSION_MAJOR 1
#define EVHTP_VERSION_MINOR 2
-#define EVHTP_VERSION_PATCH 2
+#define EVHTP_VERSION_PATCH 3
#define evhtp_headers_iterator evhtp_kvs_iterator
@@ -256,26 +256,27 @@ struct evhtp_alias_s {
* @brief main structure containing all configuration information
*/
struct evhtp_s {
- evhtp_t * parent; /**< only when this is a vhost */
- evbase_t * evbase; /**< the initialized event_base */
- evserv_t * server; /**< the libevent listener struct */
- char * server_name; /**< the name included in Host: responses */
- void * arg; /**< user-defined evhtp_t specific arguments */
- int bev_flags; /**< bufferevent flags to use on bufferevent_*_socket_new() */
+ evhtp_t * parent; /**< only when this is a vhost */
+ evbase_t * evbase; /**< the initialized event_base */
+ evserv_t * server; /**< the libevent listener struct */
+ char * server_name; /**< the name included in Host: responses */
+ void * arg; /**< user-defined evhtp_t specific arguments */
+ int bev_flags; /**< bufferevent flags to use on bufferevent_*_socket_new() */
uint64_t max_body_size;
uint64_t max_keepalive_requests;
+ int disable_100_cont; /**< if set, evhtp will not respond to Expect: 100-continue */
#ifndef DISABLE_SSL
- evhtp_ssl_ctx_t * ssl_ctx; /**< if ssl enabled, this is the servers CTX */
+ evhtp_ssl_ctx_t * ssl_ctx; /**< if ssl enabled, this is the servers CTX */
evhtp_ssl_cfg_t * ssl_cfg;
#endif
#ifndef EVHTP_DISABLE_EVTHR
- evthr_pool_t * thr_pool; /**< connection threadpool */
+ evthr_pool_t * thr_pool; /**< connection threadpool */
#endif
#ifndef EVHTP_DISABLE_EVTHR
- pthread_mutex_t * lock; /**< parent lock for add/del cbs in threads */
+ pthread_mutex_t * lock; /**< parent lock for add/del cbs in threads */
evhtp_thread_init_cb thread_init_cb;
void * thread_init_cbarg;
#endif
@@ -523,6 +524,14 @@ int evhtp_ssl_init(evhtp_t * htp, evhtp_ssl_cfg_t * ssl_cfg);
/**
+ * @brief when a client sends an Expect: 100-continue, if this is function is
+ * called, evhtp will not send a HTTP/x.x continue response.
+ *
+ * @param htp
+ */
+void evhtp_disable_100_continue(evhtp_t * htp);
+
+/**
* @brief creates a lock around callbacks and hooks, allowing for threaded
* applications to add/remove/modify hooks & callbacks in a thread-safe manner.
*
View
2 examples/test.c
@@ -294,7 +294,7 @@ print_data(evhtp_request_t * req, evbuf_t * buf, void * arg) {
evbuffer_add_printf(req->buffer_out,
"got %zu bytes of data\n",
evbuffer_get_length(buf));
- printf("%.*s", (int)evbuffer_get_length(buf), (char *)evbuffer_pullup(buf, evbuffer_get_length(buf)));
+ //printf("%.*s", (int)evbuffer_get_length(buf), (char *)evbuffer_pullup(buf, evbuffer_get_length(buf)));
#endif
evbuffer_drain(buf, -1);
return EVHTP_RES_OK;

0 comments on commit 826a0b2

Please sign in to comment.