comparison src/http/ngx_http_request_body.c @ 438:ce4f9ff90bfa NGINX_0_7_31

nginx 0.7.31 *) Change: now the "try_files" directive tests files only and ignores directories. *) Feature: the "fastcgi_split_path_info" directive. *) Bugfixes in an "Expect" request header line support. *) Bugfixes in geo ranges. *) Bugfix: in a miss case ngx_http_memcached_module returned the "END" line as response body instead of default 404 page body; the bug had appeared in 0.7.18. Thanks to Maxim Dounin. *) Bugfix: while SMTP proxying nginx issued message "250 2.0.0 OK" instead of "235 2.0.0 OK"; the bug had appeared in 0.7.22. Thanks to Maxim Dounin.
author Igor Sysoev <http://sysoev.ru>
date Mon, 19 Jan 2009 00:00:00 +0300
parents dac47e9ef0d5
children 86dad910eeb6
comparison
equal deleted inserted replaced
437:5da91f7cde93 438:ce4f9ff90bfa
13 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r); 13 static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
14 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r, 14 static ngx_int_t ngx_http_write_request_body(ngx_http_request_t *r,
15 ngx_chain_t *body); 15 ngx_chain_t *body);
16 static void ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r); 16 static void ngx_http_read_discarded_request_body_handler(ngx_http_request_t *r);
17 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r); 17 static ngx_int_t ngx_http_read_discarded_request_body(ngx_http_request_t *r);
18 static ngx_int_t ngx_http_test_expect(ngx_http_request_t *r);
18 19
19 20
20 /* 21 /*
21 * on completion ngx_http_read_client_request_body() adds to 22 * on completion ngx_http_read_client_request_body() adds to
22 * r->request_body->bufs one or two bufs: 23 * r->request_body->bufs one or two bufs:
37 ngx_http_core_loc_conf_t *clcf; 38 ngx_http_core_loc_conf_t *clcf;
38 39
39 if (r->request_body || r->discard_body) { 40 if (r->request_body || r->discard_body) {
40 post_handler(r); 41 post_handler(r);
41 return NGX_OK; 42 return NGX_OK;
43 }
44
45 if (ngx_http_test_expect(r) != NGX_OK) {
46 return NGX_HTTP_INTERNAL_SERVER_ERROR;
42 } 47 }
43 48
44 rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)); 49 rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
45 if (rb == NULL) { 50 if (rb == NULL) {
46 return NGX_HTTP_INTERNAL_SERVER_ERROR; 51 return NGX_HTTP_INTERNAL_SERVER_ERROR;
431 436
432 if (r != r->main || r->discard_body) { 437 if (r != r->main || r->discard_body) {
433 return NGX_OK; 438 return NGX_OK;
434 } 439 }
435 440
441 if (ngx_http_test_expect(r) != NGX_OK) {
442 return NGX_HTTP_INTERNAL_SERVER_ERROR;
443 }
444
436 rev = r->connection->read; 445 rev = r->connection->read;
437 446
438 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http set discard body"); 447 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, rev->log, 0, "http set discard body");
439 448
440 if (rev->timer_set) { 449 if (rev->timer_set) {
579 588
580 } while (r->connection->read->ready); 589 } while (r->connection->read->ready);
581 590
582 return NGX_AGAIN; 591 return NGX_AGAIN;
583 } 592 }
593
594
595 static ngx_int_t
596 ngx_http_test_expect(ngx_http_request_t *r)
597 {
598 ngx_int_t n;
599 ngx_str_t *expect;
600
601 if (r->expect_tested
602 || r->headers_in.expect == NULL
603 || r->http_version < NGX_HTTP_VERSION_11)
604 {
605 return NGX_OK;
606 }
607
608 r->expect_tested = 1;
609
610 expect = &r->headers_in.expect->value;
611
612 if (expect->len != sizeof("100-continue") - 1
613 || ngx_strncasecmp(expect->data, (u_char *) "100-continue",
614 sizeof("100-continue") - 1)
615 != 0)
616 {
617 return NGX_OK;
618 }
619
620 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
621 "send 100 Continue");
622
623 n = r->connection->send(r->connection,
624 (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
625 sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
626
627 if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
628 return NGX_OK;
629 }
630
631 /* we assume that such small packet should be send successfully */
632
633 return NGX_ERROR;
634 }