diff options
author | Igor Sysoev <igor@sysoev.ru> | 2008-06-26 13:00:39 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2008-06-26 13:00:39 +0000 |
commit | 1e1f4c8a04f32907c1b9e263ec45bf20bb6210bb (patch) | |
tree | d438f11f031241622edd79953dc4dcd91ff63187 /src/http/ngx_http_core_module.c | |
parent | 24329bf299b2ce4f4d9b02306651e1d64a4c6216 (diff) | |
download | nginx-1e1f4c8a04f32907c1b9e263ec45bf20bb6210bb.tar.gz nginx-1e1f4c8a04f32907c1b9e263ec45bf20bb6210bb.zip |
the "Expect" header support
Diffstat (limited to 'src/http/ngx_http_core_module.c')
-rw-r--r-- | src/http/ngx_http_core_module.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index aa557c450..f7b8b5b17 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -25,6 +25,7 @@ typedef struct { static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r); static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r, ngx_http_location_tree_node_t *node); +static ngx_int_t ngx_http_core_send_continue(ngx_http_request_t *r); static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf); static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); @@ -771,7 +772,7 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r, { u_char *p; size_t len; - ngx_int_t rc; + ngx_int_t rc, expect; ngx_http_core_loc_conf_t *clcf; r->content_handler = NULL; @@ -815,6 +816,15 @@ ngx_http_core_find_config_phase(ngx_http_request_t *r, return NGX_OK; } + if (r->headers_in.expect) { + expect = ngx_http_core_send_continue(r); + + if (expect != NGX_OK) { + ngx_http_finalize_request(r, expect); + return NGX_OK; + } + } + if (rc == NGX_DONE) { r->headers_out.location = ngx_list_push(&r->headers_out.headers); if (r->headers_out.location == NULL) { @@ -1244,6 +1254,45 @@ ngx_http_core_find_static_location(ngx_http_request_t *r, } +static ngx_int_t +ngx_http_core_send_continue(ngx_http_request_t *r) +{ + ngx_int_t n; + ngx_str_t *expect; + + if (r->expect_tested) { + return NGX_OK; + } + + r->expect_tested = 1; + + expect = &r->headers_in.expect->value; + + if (expect->len != sizeof("100-continue") - 1 + || ngx_strncasecmp(expect->data, (u_char *) "100-continue", + sizeof("100-continue") - 1) + != 0) + { + return NGX_OK; + } + + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "send 100 Continue"); + + n = r->connection->send(r->connection, + (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF, + sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1); + + if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) { + return NGX_OK; + } + + /* we assume that such small packet should be send successfully */ + + return NGX_HTTP_INTERNAL_SERVER_ERROR; +} + + ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r) { |