comparison src/http/ngx_http_core_module.c @ 248:acd2ec3541cb NGINX_0_4_9

nginx 0.4.9 *) Feature: the "set" parameter in the "include" SSI command. *) Feature: the ngx_http_perl_module now tests the nginx.pm module version.
author Igor Sysoev <http://sysoev.ru>
date Fri, 13 Oct 2006 00:00:00 +0400
parents 500a3242dff6
children 644510700914
comparison
equal deleted inserted replaced
247:fcca101509a4 248:acd2ec3541cb
792 792
793 ngx_int_t 793 ngx_int_t
794 ngx_http_core_content_phase(ngx_http_request_t *r, 794 ngx_http_core_content_phase(ngx_http_request_t *r,
795 ngx_http_phase_handler_t *ph) 795 ngx_http_phase_handler_t *ph)
796 { 796 {
797 size_t root;
797 ngx_int_t rc; 798 ngx_int_t rc;
798 ngx_str_t path; 799 ngx_str_t path;
799 800
800 if (r->content_handler) { 801 if (r->content_handler) {
801 r->write_event_handler = ngx_http_request_empty_handler; 802 r->write_event_handler = ngx_http_request_empty_handler;
828 829
829 /* no content handler was found */ 830 /* no content handler was found */
830 831
831 if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) { 832 if (r->uri.data[r->uri.len - 1] == '/' && !r->zero_in_uri) {
832 833
833 if (ngx_http_map_uri_to_path(r, &path, 0) != NULL) { 834 if (ngx_http_map_uri_to_path(r, &path, &root, 0) != NULL) {
834 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, 835 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
835 "directory index of \"%V\" is forbidden", &path); 836 "directory index of \"%V\" is forbidden", &path);
836 } 837 }
837 838
838 ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN); 839 ngx_http_finalize_request(r, NGX_HTTP_FORBIDDEN);
1155 } 1156 }
1156 1157
1157 1158
1158 u_char * 1159 u_char *
1159 ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path, 1160 ngx_http_map_uri_to_path(ngx_http_request_t *r, ngx_str_t *path,
1160 size_t reserved) 1161 size_t *root_length, size_t reserved)
1161 { 1162 {
1162 u_char *last; 1163 u_char *last;
1163 size_t alias; 1164 size_t alias;
1164 ngx_http_core_loc_conf_t *clcf; 1165 ngx_http_core_loc_conf_t *clcf;
1165 1166
1176 1177
1177 reserved += r->uri.len - alias + 1; 1178 reserved += r->uri.len - alias + 1;
1178 1179
1179 if (clcf->root_lengths == NULL) { 1180 if (clcf->root_lengths == NULL) {
1180 1181
1181 r->root_length = clcf->root.len; 1182 *root_length = clcf->root.len;
1182 1183
1183 path->len = clcf->root.len + reserved; 1184 path->len = clcf->root.len + reserved;
1184 1185
1185 path->data = ngx_palloc(r->pool, path->len); 1186 path->data = ngx_palloc(r->pool, path->len);
1186 if (path->data == NULL) { 1187 if (path->data == NULL) {
1199 1200
1200 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path) == NGX_ERROR) { 1201 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, path) == NGX_ERROR) {
1201 return NULL; 1202 return NULL;
1202 } 1203 }
1203 1204
1204 r->root_length = path->len - reserved; 1205 *root_length = path->len - reserved;
1205 last = path->data + r->root_length; 1206 last = path->data + *root_length;
1206 } 1207 }
1207 1208
1208 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1); 1209 last = ngx_cpystrn(last, r->uri.data + alias, r->uri.len - alias + 1);
1209 1210
1210 return last; 1211 return last;
1282 1283
1283 1284
1284 ngx_int_t 1285 ngx_int_t
1285 ngx_http_subrequest(ngx_http_request_t *r, 1286 ngx_http_subrequest(ngx_http_request_t *r,
1286 ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr, 1287 ngx_str_t *uri, ngx_str_t *args, ngx_http_request_t **psr,
1287 ngx_chain_t *out, ngx_uint_t flags) 1288 ngx_http_post_subrequest_t *ps, ngx_uint_t flags)
1288 { 1289 {
1289 ngx_connection_t *c; 1290 ngx_connection_t *c;
1290 ngx_http_request_t *sr; 1291 ngx_http_request_t *sr;
1291 ngx_http_log_ctx_t *ctx; 1292 ngx_http_log_ctx_t *ctx;
1292 ngx_http_core_srv_conf_t *cscf; 1293 ngx_http_core_srv_conf_t *cscf;
1339 1340
1340 sr->request_body = r->request_body; 1341 sr->request_body = r->request_body;
1341 1342
1342 sr->method = NGX_HTTP_GET; 1343 sr->method = NGX_HTTP_GET;
1343 sr->http_version = r->http_version; 1344 sr->http_version = r->http_version;
1344 sr->http_major = r->http_minor;
1345 1345
1346 sr->request_line = r->request_line; 1346 sr->request_line = r->request_line;
1347 sr->uri = *uri; 1347 sr->uri = *uri;
1348 1348
1349 if (args) { 1349 if (args) {
1351 } 1351 }
1352 1352
1353 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, 1353 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0,
1354 "http subrequest \"%V?%V\"", uri, &sr->args); 1354 "http subrequest \"%V?%V\"", uri, &sr->args);
1355 1355
1356 if (flags & NGX_HTTP_ZERO_IN_URI) { 1356 sr->zero_in_uri = (flags & NGX_HTTP_ZERO_IN_URI) != 0;
1357 sr->zero_in_uri = 1; 1357 sr->subrequest_in_memory = (flags & NGX_HTTP_SUBREQUEST_IN_MEMORY) != 0;
1358 }
1359 1358
1360 sr->unparsed_uri = r->unparsed_uri; 1359 sr->unparsed_uri = r->unparsed_uri;
1361 sr->method_name = r->method_name; 1360 sr->method_name = r->method_name;
1362 sr->http_protocol = r->http_protocol; 1361 sr->http_protocol = r->http_protocol;
1363 1362
1364 if (ngx_http_set_exten(sr) != NGX_OK) { 1363 if (ngx_http_set_exten(sr) != NGX_OK) {
1365 return NGX_ERROR; 1364 return NGX_ERROR;
1366 } 1365 }
1367 1366
1368 sr->out = out;
1369 sr->main = r->main; 1367 sr->main = r->main;
1370 sr->parent = r; 1368 sr->parent = r;
1369 sr->post_subrequest = ps;
1371 sr->read_event_handler = ngx_http_request_empty_handler; 1370 sr->read_event_handler = ngx_http_request_empty_handler;
1372 sr->write_event_handler = ngx_http_request_empty_handler; 1371 sr->write_event_handler = ngx_http_request_empty_handler;
1373 1372
1374 if (c->data == r) { 1373 if (c->data == r) {
1375 c->data = sr; 1374 c->data = sr;
1429 } 1428 }
1430 1429
1431 return NGX_AGAIN; 1430 return NGX_AGAIN;
1432 } 1431 }
1433 1432
1434 return NGX_OK; 1433 return NGX_DONE;
1435 } 1434 }
1436 1435
1437 1436
1438 ngx_int_t 1437 ngx_int_t
1439 ngx_http_internal_redirect(ngx_http_request_t *r, 1438 ngx_http_internal_redirect(ngx_http_request_t *r,