comparison src/http/ngx_http_core_module.c @ 380:3ce4580ae286 NGINX_0_6_34

nginx 0.6.34 *) Change: now the EAGAIN error returned by connect() is not considered as temporary error. *) Change: now the "gzip_vary" directive turned on issues a "Vary: Accept-Encoding" header line for uncompressed responses too. *) Feature: the "expires" directive supports daily time. *) Feature: the "Expect" request header line support. *) Feature: now the "rewrite" directive does a redirect automatically if the "https://" protocol is used. *) Bugfix: the "listen" directive parameters such as "backlog", "rcvbuf", etc. were not set, if a default server was not the first one. *) Bugfix: the "log_not_found" directive did not work for index files tests. *) Bugfix: now if FastCGI server sends a "Location" header line without status line, then nginx uses 302 status code. Thanks to Maxim Dounin. *) Bugfix: the ngx_http_flv_module did not support several values in a query string. *) Bugfix: when a request to a directory was redirected with the slash added, nginx dropped a query string from the original request.
author Igor Sysoev <http://sysoev.ru>
date Thu, 27 Nov 2008 00:00:00 +0300
parents d13234035cad
children e9979466be2f
comparison
equal deleted inserted replaced
379:522189e0ef36 380:3ce4580ae286
28 #define NGX_HTTP_REQUEST_BODY_FILE_CLEAN 2 28 #define NGX_HTTP_REQUEST_BODY_FILE_CLEAN 2
29 29
30 30
31 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r, 31 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r,
32 ngx_array_t *locations, ngx_uint_t regex_start, size_t len); 32 ngx_array_t *locations, ngx_uint_t regex_start, size_t len);
33 static ngx_int_t ngx_http_core_send_continue(ngx_http_request_t *r);
33 34
34 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf); 35 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
35 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); 36 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
36 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); 37 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
37 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); 38 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
783 ngx_http_core_find_config_phase(ngx_http_request_t *r, 784 ngx_http_core_find_config_phase(ngx_http_request_t *r,
784 ngx_http_phase_handler_t *ph) 785 ngx_http_phase_handler_t *ph)
785 { 786 {
786 u_char *p; 787 u_char *p;
787 size_t len; 788 size_t len;
788 ngx_int_t rc; 789 ngx_int_t rc, expect;
789 ngx_http_core_loc_conf_t *clcf; 790 ngx_http_core_loc_conf_t *clcf;
790 ngx_http_core_srv_conf_t *cscf; 791 ngx_http_core_srv_conf_t *cscf;
791 792
792 r->content_handler = NULL; 793 r->content_handler = NULL;
793 r->uri_changed = 0; 794 r->uri_changed = 0;
830 831
831 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); 832 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
832 return NGX_OK; 833 return NGX_OK;
833 } 834 }
834 835
836 if (r->headers_in.expect) {
837 expect = ngx_http_core_send_continue(r);
838
839 if (expect != NGX_OK) {
840 ngx_http_finalize_request(r, expect);
841 return NGX_OK;
842 }
843 }
835 844
836 if (rc == NGX_HTTP_LOCATION_AUTO_REDIRECT) { 845 if (rc == NGX_HTTP_LOCATION_AUTO_REDIRECT) {
837 r->headers_out.location = ngx_list_push(&r->headers_out.headers); 846 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
838 if (r->headers_out.location == NULL) { 847 if (r->headers_out.location == NULL) {
839 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 848 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
1247 } 1256 }
1248 1257
1249 #endif /* NGX_PCRE */ 1258 #endif /* NGX_PCRE */
1250 1259
1251 return NGX_OK; 1260 return NGX_OK;
1261 }
1262
1263
1264 static ngx_int_t
1265 ngx_http_core_send_continue(ngx_http_request_t *r)
1266 {
1267 ngx_int_t n;
1268 ngx_str_t *expect;
1269
1270 if (r->expect_tested) {
1271 return NGX_OK;
1272 }
1273
1274 r->expect_tested = 1;
1275
1276 expect = &r->headers_in.expect->value;
1277
1278 if (expect->len != sizeof("100-continue") - 1
1279 || ngx_strncasecmp(expect->data, (u_char *) "100-continue",
1280 sizeof("100-continue") - 1)
1281 != 0)
1282 {
1283 return NGX_OK;
1284 }
1285
1286 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1287 "send 100 Continue");
1288
1289 n = r->connection->send(r->connection,
1290 (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
1291 sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
1292
1293 if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
1294 return NGX_OK;
1295 }
1296
1297 /* we assume that such small packet should be send successfully */
1298
1299 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1252 } 1300 }
1253 1301
1254 1302
1255 ngx_int_t 1303 ngx_int_t
1256 ngx_http_set_content_type(ngx_http_request_t *r) 1304 ngx_http_set_content_type(ngx_http_request_t *r)