comparison src/http/ngx_http_core_module.c @ 384:12defd37f578 NGINX_0_7_4

nginx 0.7.4 *) Feature: variables support in the "access_log" directive. *) Feature: the "open_log_file_cache" directive. *) Feature: the -g switch. *) Feature: the "Expect" request header line support. *) Bugfix: large SSI inclusions might be truncated.
author Igor Sysoev <http://sysoev.ru>
date Mon, 30 Jun 2008 00:00:00 +0400
parents 984bb0b1399b
children 6de24473fa70
comparison
equal deleted inserted replaced
383:6ee3ada01457 384:12defd37f578
23 23
24 24
25 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r); 25 static ngx_int_t ngx_http_core_find_location(ngx_http_request_t *r);
26 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r, 26 static ngx_int_t ngx_http_core_find_static_location(ngx_http_request_t *r,
27 ngx_http_location_tree_node_t *node); 27 ngx_http_location_tree_node_t *node);
28 static ngx_int_t ngx_http_core_send_continue(ngx_http_request_t *r);
28 29
29 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf); 30 static ngx_int_t ngx_http_core_preconfiguration(ngx_conf_t *cf);
30 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf); 31 static void *ngx_http_core_create_main_conf(ngx_conf_t *cf);
31 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf); 32 static char *ngx_http_core_init_main_conf(ngx_conf_t *cf, void *conf);
32 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf); 33 static void *ngx_http_core_create_srv_conf(ngx_conf_t *cf);
769 ngx_http_core_find_config_phase(ngx_http_request_t *r, 770 ngx_http_core_find_config_phase(ngx_http_request_t *r,
770 ngx_http_phase_handler_t *ph) 771 ngx_http_phase_handler_t *ph)
771 { 772 {
772 u_char *p; 773 u_char *p;
773 size_t len; 774 size_t len;
774 ngx_int_t rc; 775 ngx_int_t rc, expect;
775 ngx_http_core_loc_conf_t *clcf; 776 ngx_http_core_loc_conf_t *clcf;
776 777
777 r->content_handler = NULL; 778 r->content_handler = NULL;
778 r->uri_changed = 0; 779 r->uri_changed = 0;
779 780
813 814
814 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); 815 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
815 return NGX_OK; 816 return NGX_OK;
816 } 817 }
817 818
819 if (r->headers_in.expect) {
820 expect = ngx_http_core_send_continue(r);
821
822 if (expect != NGX_OK) {
823 ngx_http_finalize_request(r, expect);
824 return NGX_OK;
825 }
826 }
827
818 if (rc == NGX_DONE) { 828 if (rc == NGX_DONE) {
819 r->headers_out.location = ngx_list_push(&r->headers_out.headers); 829 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
820 if (r->headers_out.location == NULL) { 830 if (r->headers_out.location == NULL) {
821 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 831 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
822 return NGX_OK; 832 return NGX_OK;
1239 rv = NGX_DONE; 1249 rv = NGX_DONE;
1240 } 1250 }
1241 1251
1242 node = node->left; 1252 node = node->left;
1243 } 1253 }
1254 }
1255
1256
1257 static ngx_int_t
1258 ngx_http_core_send_continue(ngx_http_request_t *r)
1259 {
1260 ngx_int_t n;
1261 ngx_str_t *expect;
1262
1263 if (r->expect_tested) {
1264 return NGX_OK;
1265 }
1266
1267 r->expect_tested = 1;
1268
1269 expect = &r->headers_in.expect->value;
1270
1271 if (expect->len != sizeof("100-continue") - 1
1272 || ngx_strncasecmp(expect->data, (u_char *) "100-continue",
1273 sizeof("100-continue") - 1)
1274 != 0)
1275 {
1276 return NGX_OK;
1277 }
1278
1279 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1280 "send 100 Continue");
1281
1282 n = r->connection->send(r->connection,
1283 (u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
1284 sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
1285
1286 if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
1287 return NGX_OK;
1288 }
1289
1290 /* we assume that such small packet should be send successfully */
1291
1292 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1244 } 1293 }
1245 1294
1246 1295
1247 ngx_int_t 1296 ngx_int_t
1248 ngx_http_set_content_type(ngx_http_request_t *r) 1297 ngx_http_set_content_type(ngx_http_request_t *r)