comparison src/http/ngx_http_core_module.c @ 99:a059e1aa65d4

nginx-0.0.1-2003-06-02-19:24:30 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 02 Jun 2003 15:24:30 +0000
parents c9b243802a17
children 7ebc8b7fb816
comparison
equal deleted inserted replaced
98:c9b243802a17 99:a059e1aa65d4
4 4
5 /* ???? */ 5 /* ???? */
6 #include <ngx_listen.h> 6 #include <ngx_listen.h>
7 7
8 #include <ngx_http.h> 8 #include <ngx_http.h>
9 #include <ngx_http_output_filter.h>
10
11 #include <nginx.h> 9 #include <nginx.h>
12 10
13 11
14 /* STUB */ 12 /* STUB */
15 int ngx_http_static_handler(ngx_http_request_t *r); 13 int ngx_http_static_handler(ngx_http_request_t *r);
95 NGX_HTTP_SRV_CONF_OFFSET, 93 NGX_HTTP_SRV_CONF_OFFSET,
96 0, 94 0,
97 NULL}, 95 NULL},
98 96
99 {ngx_string("listen"), 97 {ngx_string("listen"),
98 #if 0
100 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1, 99 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
100 #else
101 NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
102 #endif
101 ngx_set_listen, 103 ngx_set_listen,
102 NGX_HTTP_SRV_CONF_OFFSET, 104 NGX_HTTP_SRV_CONF_OFFSET,
103 0, 105 0,
104 NULL}, 106 NULL},
105 107
106 {ngx_string("server_name"), 108 {ngx_string("server_name"),
107 NGX_HTTP_SRV_CONF|NGX_CONF_ANY1, 109 NGX_HTTP_SRV_CONF|NGX_CONF_1MORE,
108 ngx_set_server_name, 110 ngx_set_server_name,
109 NGX_HTTP_SRV_CONF_OFFSET, 111 NGX_HTTP_SRV_CONF_OFFSET,
110 0, 112 0,
111 NULL}, 113 NULL},
112 114
193 195
194 196
195 void ngx_http_handler(ngx_http_request_t *r) 197 void ngx_http_handler(ngx_http_request_t *r)
196 { 198 {
197 int rc, i; 199 int rc, i;
200 ngx_http_log_ctx_t *lcx;
198 ngx_http_handler_pt *h; 201 ngx_http_handler_pt *h;
199 ngx_http_core_loc_conf_t *clcf, **clcfp; 202 ngx_http_core_loc_conf_t *clcf, **clcfp;
200 ngx_http_core_srv_conf_t *cscf; 203 ngx_http_core_srv_conf_t *cscf;
201 204
202 r->connection->unexpected_eof = 0; 205 r->connection->unexpected_eof = 0;
206
207 lcx = r->connection->log->data;
208 lcx->action = NULL;
203 209
204 r->keepalive = 1; 210 r->keepalive = 1;
205 211
206 if (r->headers_in.content_length_n > 0) { 212 if (r->headers_in.content_length_n > 0) {
207 r->lingering_close = 1; 213 r->lingering_close = 1;
335 } 341 }
336 342
337 #else 343 #else
338 344
339 if (r->file.fd == NGX_INVALID_FILE) { 345 if (r->file.fd == NGX_INVALID_FILE) {
340 r->file.fd = ngx_open_file(r->file.name.data, NGX_FILE_RDONLY); 346 r->file.fd = ngx_open_file(r->file.name.data,
347 NGX_FILE_RDONLY, NGX_FILE_OPEN);
341 } 348 }
342 349
343 if (r->file.fd == NGX_INVALID_FILE) { 350 if (r->file.fd == NGX_INVALID_FILE) {
344 err = ngx_errno; 351 err = ngx_errno;
345 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno, 352 ngx_log_error(NGX_LOG_ERR, r->connection->log, ngx_errno,
365 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 372 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
366 ngx_close_file_n " \"%s\" failed", 373 ngx_close_file_n " \"%s\" failed",
367 r->file.name.data); 374 r->file.name.data);
368 } 375 }
369 376
377 r->file.fd = NGX_INVALID_FILE;
378
370 return NGX_HTTP_INTERNAL_SERVER_ERROR; 379 return NGX_HTTP_INTERNAL_SERVER_ERROR;
371 } 380 }
372 381
373 r->file.info_valid = 1; 382 r->file.info_valid = 1;
374 } 383 }
380 #if !(WIN9X) 389 #if !(WIN9X)
381 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) { 390 if (ngx_close_file(r->file.fd) == NGX_FILE_ERROR) {
382 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno, 391 ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
383 ngx_close_file_n " \"%s\" failed", r->file.name.data); 392 ngx_close_file_n " \"%s\" failed", r->file.name.data);
384 } 393 }
394
395 r->file.fd = NGX_INVALID_FILE;
385 #endif 396 #endif
386 397
387 /* BROKEN: need to include server name */ 398 /* BROKEN: need to include server name */
388 399
389 ngx_test_null(h, ngx_push_table(r->headers_out.headers), 400 ngx_test_null(h, ngx_push_table(r->headers_out.headers),
780 int len; 791 int len;
781 ngx_err_t err; 792 ngx_err_t err;
782 ngx_http_listen_t *l; 793 ngx_http_listen_t *l;
783 ngx_http_server_name_t *n; 794 ngx_http_server_name_t *n;
784 795
785 /* TODO: it does not merge, it init only */ 796 /* TODO: it does not merge, it inits only */
786 797
787 if (conf->listen.nelts == 0) { 798 if (conf->listen.nelts == 0) {
788 ngx_test_null(l, ngx_push_array(&conf->listen), NGX_CONF_ERROR); 799 ngx_test_null(l, ngx_push_array(&conf->listen), NGX_CONF_ERROR);
789 l->addr = INADDR_ANY; 800 l->addr = INADDR_ANY;
790 l->port = 8000; 801 /* STUB: getuid() should be cached */
802 l->port = (getuid() == 0) ? 80 : 8000;
791 l->family = AF_INET; 803 l->family = AF_INET;
792 } 804 }
793 805
794 if (conf->server_names.nelts == 0) { 806 if (conf->server_names.nelts == 0) {
795 ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR); 807 ngx_test_null(n, ngx_push_array(&conf->server_names), NGX_CONF_ERROR);
869 ngx_http_core_loc_conf_t *conf = child; 881 ngx_http_core_loc_conf_t *conf = child;
870 882
871 int i, key; 883 int i, key;
872 ngx_http_type_t *t; 884 ngx_http_type_t *t;
873 885
874 ngx_conf_merge_str_value(conf->doc_root, 886 ngx_conf_merge_str_value(conf->doc_root, prev->doc_root, "html");
875 prev->doc_root, "html");
876 887
877 if (conf->types == NULL) { 888 if (conf->types == NULL) {
878 if (prev->types) { 889 if (prev->types) {
879 conf->types = prev->types; 890 conf->types = prev->types;
880 891