comparison src/http/ngx_http_event.c @ 54:27b628ef907e

nginx-0.0.1-2003-01-28-18:56:37 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 28 Jan 2003 15:56:37 +0000
parents d1e42f1b8fd4
children cad6c2f43283
comparison
equal deleted inserted replaced
53:d1e42f1b8fd4 54:27b628ef907e
371 } 371 }
372 372
373 373
374 static int ngx_http_process_request_headers(ngx_http_request_t *r) 374 static int ngx_http_process_request_headers(ngx_http_request_t *r)
375 { 375 {
376 int rc; 376 int rc, len;
377 ngx_http_log_ctx_t *ctx; 377 ngx_http_log_ctx_t *ctx;
378 378
379 for ( ;; ) { 379 for ( ;; ) {
380 rc = ngx_read_http_header_line(r, r->header_in); 380 rc = ngx_read_http_header_line(r, r->header_in);
381 381
382 /* TODO: check too long header, compact buffer */ 382 /* TODO: check too long header, compact buffer */
383 383
384 if (rc == NGX_OK) { 384 if (rc == NGX_OK) { /* header line is ready */
385 if (ngx_http_process_request_header_line(r) == NGX_ERROR) 385 if (ngx_http_process_request_header_line(r) == NGX_ERROR) {
386 return ngx_http_error(r, NGX_HTTP_BAD_REQUEST); 386 return ngx_http_error(r, NGX_HTTP_BAD_REQUEST);
387 }
388
389 return NGX_AGAIN;
387 390
388 } else if (rc == NGX_HTTP_PARSE_HEADER_DONE) { 391 } else if (rc == NGX_HTTP_PARSE_HEADER_DONE) {
389 ngx_log_debug(r->connection->log, "HTTP header done"); 392 ngx_log_debug(r->connection->log, "HTTP header done");
390 393
391 if (r->http_version > NGX_HTTP_VERSION_10 394 if (r->headers_in.host) {
392 && r->headers_in.host == NULL) 395 for (len = 0; len < r->headers_in.host->value.len; len++) {
393 { 396 if (r->headers_in.host->value.data[len] == ':') {
394 return ngx_http_error(r, NGX_HTTP_BAD_REQUEST); 397 break;
398 }
399 }
400 r->headers_in.host_name.len = len;
401 r->headers_in.host_name.data = r->headers_in.host->value.data;
402
395 } else { 403 } else {
396 return NGX_OK; 404 if (r->http_version > NGX_HTTP_VERSION_10) {
405 return ngx_http_error(r, NGX_HTTP_BAD_REQUEST);
406 }
407 r->headers_in.host_name.len = 0;
397 } 408 }
409
410 return NGX_OK;
398 411
399 } else if (rc == NGX_AGAIN) { 412 } else if (rc == NGX_AGAIN) {
400 return NGX_AGAIN; 413 return NGX_AGAIN;
401 414
402 } else if (rc == NGX_HTTP_PARSE_INVALID_HEADER) { 415 } else if (rc == NGX_HTTP_PARSE_INVALID_HEADER) {
427 ngx_test_null(h->value.data, ngx_palloc(r->pool, h->value.len + 1), 440 ngx_test_null(h->value.data, ngx_palloc(r->pool, h->value.len + 1),
428 NGX_ERROR); 441 NGX_ERROR);
429 ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1); 442 ngx_cpystrn(h->value.data, r->header_start, h->value.len + 1);
430 443
431 for (i = 0; headers_in[i].len != 0; i++) { 444 for (i = 0; headers_in[i].len != 0; i++) {
432 if (headers_in[i].len == h->key.len) { 445 if (headers_in[i].len != h->key.len) {
433 if (ngx_strcasecmp(headers_in[i].data, h->key.data) == 0) { 446 continue;
434 *((ngx_table_elt_t **) 447 }
435 ((char *) &r->headers_in + headers_in[i].offset)) = h; 448
436 } 449 if (ngx_strcasecmp(headers_in[i].data, h->key.data) == 0) {
450 *((ngx_table_elt_t **)
451 ((char *) &r->headers_in + headers_in[i].offset)) = h;
437 } 452 }
438 } 453 }
439 454
440 ngx_log_debug(r->connection->log, "HTTP header: '%s: %s'" _ 455 ngx_log_debug(r->connection->log, "HTTP header: '%s: %s'" _
441 h->key.data _ h->value.data); 456 h->key.data _ h->value.data);