diff --git a/NEWS b/NEWS index 2abd9719..5ff1fd2d 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ NEWS * Disable SSLv2 by default * Use/enforce sane max-connection values (fixes #1803) * Allow mod_compress to return 304 (Not Modified); compress ignores the static-file.etags option.(fixes #1884) + * Add option to ignore the "Expect: 100-continue" header instead of returning 417 Expectation failed (closes #1017) - 1.4.20 - 2008-09-30 diff --git a/src/base.h b/src/base.h index 3de6d77b..00186c9b 100644 --- a/src/base.h +++ b/src/base.h @@ -497,6 +497,7 @@ typedef struct { #endif } stat_cache_engine; unsigned short enable_cores; + unsigned short reject_expect_100_with_417; } server_config; typedef struct { diff --git a/src/configfile.c b/src/configfile.c index a9e355ce..f5fd5c15 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -94,6 +94,7 @@ static int config_insert(server *srv) { { "etag.use-inode", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 49 */ { "etag.use-mtime", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 50 */ { "etag.use-size", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 51 */ + { "server.reject-expect-100-with-417", NULL, T_CONFIG_BOOLEAN, T_CONFIG_SCOPE_SERVER }, /* 52 */ { "server.host", "use server.bind instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, { "server.docroot", "use server.document-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, { "server.virtual-root", "load mod_simple_vhost and use simple-vhost.server-root instead", T_CONFIG_DEPRECATED, T_CONFIG_SCOPE_UNSET }, @@ -135,6 +136,7 @@ static int config_insert(server *srv) { cv[43].destination = &(srv->srvconf.max_conns); cv[12].destination = &(srv->srvconf.max_request_size); + cv[52].destination = &(srv->srvconf.reject_expect_100_with_417); srv->config_storage = calloc(1, srv->config_context->used * sizeof(specific_config *)); assert(srv->config_storage); diff --git a/src/request.c b/src/request.c index 5a02aea8..ee9ec4d7 100644 --- a/src/request.c +++ b/src/request.c @@ -894,11 +894,12 @@ int http_request_parse(server *srv, connection *con) { * */ - con->http_status = 417; - con->keep_alive = 0; - - array_insert_unique(con->request.headers, (data_unset *)ds); - return 0; + if (srv->srvconf.reject_expect_100_with_417 && 0 == buffer_caseless_compare(CONST_BUF_LEN(ds->value), CONST_STR_LEN("100-continue"))) { + con->http_status = 417; + con->keep_alive = 0; + array_insert_unique(con->request.headers, (data_unset *)ds); + return 0; + } } else if (cmp > 0 && 0 == (cmp = buffer_caseless_compare(CONST_BUF_LEN(ds->key), CONST_STR_LEN("Host")))) { if (!con->request.http_host) { con->request.http_host = ds->value; diff --git a/src/server.c b/src/server.c index 37e2712a..fddd3266 100644 --- a/src/server.c +++ b/src/server.c @@ -210,6 +210,7 @@ static server *server_init(void) { srv->srvconf.modules_dir = buffer_init_string(LIBRARY_DIR); srv->srvconf.network_backend = buffer_init(); srv->srvconf.upload_tempdirs = array_init(); + srv->srvconf.reject_expect_100_with_417 = 1; /* use syslog */ srv->errorlog_fd = -1;