comparison src/http/ngx_http_request.c @ 166:389d7ee9fa60

nginx-0.0.1-2003-10-30-11:51:06 import
author Igor Sysoev <igor@sysoev.ru>
date Thu, 30 Oct 2003 08:51:06 +0000
parents 894a01c6aea3
children edf29bb717da
comparison
equal deleted inserted replaced
165:894a01c6aea3 166:389d7ee9fa60
66 if (c->addr_text.len == 0) { 66 if (c->addr_text.len == 0) {
67 ngx_http_close_connection(c); 67 ngx_http_close_connection(c);
68 return; 68 return;
69 } 69 }
70 70
71 lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)); 71 if (!(lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
72 if (lctx == NULL) {
73 ngx_http_close_connection(c); 72 ngx_http_close_connection(c);
74 return; 73 return;
75 } 74 }
76 75
77 lctx->client = c->addr_text.data; 76 lctx->client = c->addr_text.data;
131 if (c->data) { 130 if (c->data) {
132 r = c->data; 131 r = c->data;
133 ngx_memzero(r, sizeof(ngx_http_request_t)); 132 ngx_memzero(r, sizeof(ngx_http_request_t));
134 133
135 } else { 134 } else {
136 r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)); 135 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
137 if (r == NULL) {
138 ngx_http_close_connection(c); 136 ngx_http_close_connection(c);
139 return; 137 return;
140 } 138 }
141 } 139 }
142 140
210 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 208 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
211 c->log->file = clcf->err_log->file; 209 c->log->file = clcf->err_log->file;
212 c->log->log_level = clcf->err_log->log_level; 210 c->log->log_level = clcf->err_log->log_level;
213 211
214 if (c->buffer == NULL) { 212 if (c->buffer == NULL) {
215 c->buffer = ngx_create_temp_hunk(c->pool, 213 c->buffer =
216 cscf->client_header_buffer_size, 214 ngx_create_temp_hunk(c->pool, cscf->client_header_buffer_size);
217 0, 0);
218 if (c->buffer == NULL) { 215 if (c->buffer == NULL) {
219 ngx_http_close_connection(c); 216 ngx_http_close_connection(c);
220 return; 217 return;
221 } 218 }
222 } 219 }
223 220
224 r->pool = ngx_create_pool(cscf->request_pool_size, c->log); 221 if (!(r->pool = ngx_create_pool(cscf->request_pool_size, c->log))) {
225 if (r->pool == NULL) { 222 ngx_http_close_connection(c);
226 ngx_http_close_connection(c); 223 return;
227 return; 224 }
228 } 225
229 226 if (!(r->headers_out.headers = ngx_create_table(r->pool, 20))) {
230 r->headers_out.headers = ngx_create_table(r->pool, 20);
231 if (r->headers_out.headers == NULL) {
232 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 227 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
233 ngx_http_close_connection(c); 228 ngx_http_close_connection(c);
234 return; 229 return;
235 } 230 }
236 231
288 283
289 if (rc == NGX_OK) { 284 if (rc == NGX_OK) {
290 285
291 /* the request line has been parsed successfully */ 286 /* the request line has been parsed successfully */
292 287
293 /* STUB: we need to handle such URIs */ 288 /* TODO: we need to handle such URIs */
294 if (r->complex_uri || r->unusual_uri) { 289 if (r->complex_uri || r->unusual_uri) {
295 r->request_line.len = r->request_end - r->request_start; 290 r->request_line.len = r->request_end - r->request_start;
296 r->request_line.data = r->request_start; 291 r->request_line.data = r->request_start;
297 r->request_line.data[r->request_line.len] = '\0'; 292 r->request_line.data[r->request_line.len] = '\0';
298 293
321 r->uri.len = r->args_start - 1 - r->uri_start; 316 r->uri.len = r->args_start - 1 - r->uri_start;
322 } else { 317 } else {
323 r->uri.len = r->uri_end - r->uri_start; 318 r->uri.len = r->uri_end - r->uri_start;
324 } 319 }
325 320
326 r->uri.data = ngx_palloc(r->pool, r->uri.len + 1); 321 if (!(r->uri.data = ngx_palloc(r->pool, r->uri.len + 1))) {
327 if (r->uri.data == NULL) {
328 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 322 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
329 ngx_http_close_connection(c); 323 ngx_http_close_connection(c);
330 return; 324 return;
331 } 325 }
332 326
376 r->exten.len = r->args_start - 1 - r->uri_ext; 370 r->exten.len = r->args_start - 1 - r->uri_ext;
377 } else { 371 } else {
378 r->exten.len = r->uri_end - r->uri_ext; 372 r->exten.len = r->uri_end - r->uri_ext;
379 } 373 }
380 374
381 r->exten.data = ngx_palloc(r->pool, r->exten.len + 1); 375 if (!(r->exten.data = ngx_palloc(r->pool, r->exten.len + 1))) {
382 if (r->exten.data == NULL) {
383 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 376 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
384 ngx_http_close_connection(c); 377 ngx_http_close_connection(c);
385 return; 378 return;
386 } 379 }
387 380
391 /* copy URI arguments if they exist */ 384 /* copy URI arguments if they exist */
392 385
393 if (r->args_start && r->uri_end > r->args_start) { 386 if (r->args_start && r->uri_end > r->args_start) {
394 r->args.len = r->uri_end - r->args_start; 387 r->args.len = r->uri_end - r->args_start;
395 388
396 r->args.data = ngx_palloc(r->pool, r->args.len + 1); 389 if (!(r->args.data = ngx_palloc(r->pool, r->args.len + 1))) {
397 if (r->args.data == NULL) {
398 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 390 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
399 ngx_http_close_connection(c); 391 ngx_http_close_connection(c);
400 return; 392 return;
401 } 393 }
402 394
529 521
530 if (rc == NGX_OK) { 522 if (rc == NGX_OK) {
531 523
532 /* a header line has been parsed successfully */ 524 /* a header line has been parsed successfully */
533 525
534 if (!(h = ngx_http_add_header(&r->headers_in, ngx_http_headers_in))) 526 h = ngx_http_add_header(&r->headers_in, ngx_http_headers_in);
535 { 527 if (h == NULL) {
536 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 528 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
537 ngx_http_close_connection(c); 529 ngx_http_close_connection(c);
538 return; 530 return;
539 } 531 }
540 532