Klaus Demo nginx / 1e1f4c8
the "Expect" header support Igor Sysoev 13 years ago
4 changed file(s) with 57 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
401401 { ngx_string("Host"), ngx_string("$proxy_host") },
402402 { ngx_string("Connection"), ngx_string("close") },
403403 { ngx_string("Keep-Alive"), ngx_string("") },
404 { ngx_string("Expect"), ngx_string("") },
404405 { ngx_null_string, ngx_null_string }
405406 };
406407
2424 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r);
2525 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r,
2626 ngx_http_location_tree_node_t *node);
27 static ngx_int_t ngx_http_core_send_continue(ngx_http_request_t *r);
2728
2829 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
2930 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
770771 {
771772 u_char *p;
772773 size_t len;
773 ngx_int_t rc;
774 ngx_int_t rc, expect;
774775 ngx_http_core_loc_conf_t *clcf;
775776
776777 r->content_handler = NULL;
814815 return NGX_OK;
815816 }
816817
818 if (r->headers_in.expect) {
819 expect = ngx_http_core_send_continue(r);
820
821 if (expect != NGX_OK) {
822 ngx_http_finalize_request(r, expect);
823 return NGX_OK;
824 }
825 }
826
817827 if (rc == NGX_DONE) {
818828 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
819829 if (r->headers_out.location == NULL) {
12401250
12411251 node = node->left;
12421252 }
1253 }
1254
1255
1256 static ngx_int_t
1257 ngx_http_core_send_continue(ngx_http_request_t *r)
1258 {
1259 ngx_int_t n;
1260 ngx_str_t *expect;
1261
1262 if (r->expect_tested) {
1263 return NGX_OK;
1264 }
1265
1266 r->expect_tested = 1;
1267
1268 expect = &r->headers_in.expect->value;
1269
1270 if (expect->len != sizeof("100-continue") - 1
1271 || ngx_strncasecmp(expect->data, (u_char *) "100-continue",
1272 sizeof("100-continue") - 1)
1273 != 0)
1274 {
1275 return NGX_OK;
1276 }
1277
1278 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1279 "send 100 Continue");
1280
1281 n = r->connection->send(r->connection,
1282 (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
1283 sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
1284
1285 if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
1286 return NGX_OK;
1287 }
1288
1289 /* we assume that such small packet should be send successfully */
1290
1291 return NGX_HTTP_INTERNAL_SERVER_ERROR;
12431292 }
12441293
12451294
105105 offsetof(ngx_http_headers_in_t, transfer_encoding),
106106 ngx_http_process_header_line },
107107
108 { ngx_string("Expect"),
109 offsetof(ngx_http_headers_in_t, expect),
110 ngx_http_process_unique_header_line },
111
108112 #if (NGX_HTTP_GZIP)
109113 { ngx_string("Accept-Encoding"),
110114 offsetof(ngx_http_headers_in_t, accept_encoding),
170170 ngx_table_elt_t *if_range;
171171
172172 ngx_table_elt_t *transfer_encoding;
173 ngx_table_elt_t *expect;
173174
174175 #if (NGX_HTTP_GZIP)
175176 ngx_table_elt_t *accept_encoding;
466467 unsigned request_complete:1;
467468 unsigned request_output:1;
468469 unsigned header_sent:1;
470 unsigned expect_tested:1;
469471 unsigned done:1;
470472 unsigned utf8:1;
471473