comparison src/http/ngx_http_request.c @ 191:71ce40b3c37b

nginx-0.0.1-2003-11-19-19:26:41 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 19 Nov 2003 16:26:41 +0000
parents c966c09be66b
children 31824be1fc66
comparison
equal deleted inserted replaced
190:02a715e85df1 191:71ce40b3c37b
19 19
20 static void ngx_http_set_keepalive(ngx_http_request_t *r); 20 static void ngx_http_set_keepalive(ngx_http_request_t *r);
21 static void ngx_http_keepalive_handler(ngx_event_t *ev); 21 static void ngx_http_keepalive_handler(ngx_event_t *ev);
22 static void ngx_http_set_lingering_close(ngx_http_request_t *r); 22 static void ngx_http_set_lingering_close(ngx_http_request_t *r);
23 static void ngx_http_lingering_close_handler(ngx_event_t *ev); 23 static void ngx_http_lingering_close_handler(ngx_event_t *ev);
24 static void ngx_http_empty_handler(ngx_event_t *wev);
25 24
26 static void ngx_http_client_error(ngx_http_request_t *r, 25 static void ngx_http_client_error(ngx_http_request_t *r,
27 int client_error, int error); 26 int client_error, int error);
28 static size_t ngx_http_log_error(void *data, char *buf, size_t len); 27 static size_t ngx_http_log_error(void *data, char *buf, size_t len);
29 28
50 49
51 50
52 void ngx_http_init_connection(ngx_connection_t *c) 51 void ngx_http_init_connection(ngx_connection_t *c)
53 { 52 {
54 ngx_event_t *rev; 53 ngx_event_t *rev;
55 ngx_http_log_ctx_t *lctx; 54 ngx_http_log_ctx_t *ctx;
56 55
57 c->addr_text.data = ngx_palloc(c->pool, c->listening->addr_text_max_len); 56 c->addr_text.data = ngx_palloc(c->pool, c->listening->addr_text_max_len);
58 if (c->addr_text.data == NULL) { 57 if (c->addr_text.data == NULL) {
59 ngx_http_close_connection(c); 58 ngx_http_close_connection(c);
60 return; 59 return;
66 if (c->addr_text.len == 0) { 65 if (c->addr_text.len == 0) {
67 ngx_http_close_connection(c); 66 ngx_http_close_connection(c);
68 return; 67 return;
69 } 68 }
70 69
71 if (!(lctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) { 70 if (!(ctx = ngx_pcalloc(c->pool, sizeof(ngx_http_log_ctx_t)))) {
72 ngx_http_close_connection(c); 71 ngx_http_close_connection(c);
73 return; 72 return;
74 } 73 }
75 74
76 lctx->client = c->addr_text.data; 75 ctx->connection = c->number;
77 lctx->action = "reading client request line"; 76 ctx->client = c->addr_text.data;
78 c->log->data = lctx; 77 ctx->action = "reading client request line";
78 c->log->data = ctx;
79 c->log->handler = ngx_http_log_error; 79 c->log->handler = ngx_http_log_error;
80 80
81 rev = c->read; 81 rev = c->read;
82 rev->event_handler = ngx_http_init_request; 82 rev->event_handler = ngx_http_init_request;
83 83
261 { 261 {
262 int rc, offset; 262 int rc, offset;
263 ssize_t n; 263 ssize_t n;
264 ngx_connection_t *c; 264 ngx_connection_t *c;
265 ngx_http_request_t *r; 265 ngx_http_request_t *r;
266 ngx_http_log_ctx_t *lctx; 266 ngx_http_log_ctx_t *ctx;
267 ngx_http_core_srv_conf_t *cscf; 267 ngx_http_core_srv_conf_t *cscf;
268 268
269 c = rev->data; 269 c = rev->data;
270 r = c->data; 270 r = c->data;
271 271
412 rev->event_handler = ngx_http_block_read; 412 rev->event_handler = ngx_http_block_read;
413 ngx_http_handler(r); 413 ngx_http_handler(r);
414 return; 414 return;
415 } 415 }
416 416
417 lctx = c->log->data; 417 ctx = c->log->data;
418 lctx->action = "reading client request headers"; 418 ctx->action = "reading client request headers";
419 lctx->url = r->unparsed_uri.data; 419 ctx->url = r->unparsed_uri.data;
420 /* TODO: ngx_init_table */ 420 /* TODO: ngx_init_table */
421 r->headers_in.headers = ngx_create_table(r->pool, 20); 421 r->headers_in.headers = ngx_create_table(r->pool, 20);
422 422
423 if (cscf->large_client_header 423 if (cscf->large_client_header
424 && r->header_in->pos == r->header_in->last) 424 && r->header_in->pos == r->header_in->last)
871 { 871 {
872 int rc; 872 int rc;
873 ngx_connection_t *c; 873 ngx_connection_t *c;
874 ngx_http_request_t *r; 874 ngx_http_request_t *r;
875 ngx_http_core_loc_conf_t *clcf; 875 ngx_http_core_loc_conf_t *clcf;
876
877 ngx_log_debug(wev->log, "http writer handler");
876 878
877 c = wev->data; 879 c = wev->data;
878 r = c->data; 880 r = c->data;
879 881
880 #if 0 /* TODO: THINK */ 882 #if 0 /* TODO: THINK */
1136 1138
1137 static void ngx_http_keepalive_handler(ngx_event_t *rev) 1139 static void ngx_http_keepalive_handler(ngx_event_t *rev)
1138 { 1140 {
1139 ssize_t n; 1141 ssize_t n;
1140 ngx_connection_t *c; 1142 ngx_connection_t *c;
1141 ngx_http_log_ctx_t *lctx; 1143 ngx_http_log_ctx_t *ctx;
1142 1144
1143 c = (ngx_connection_t *) rev->data; 1145 c = (ngx_connection_t *) rev->data;
1144 1146
1145 ngx_log_debug(c->log, "http keepalive handler"); 1147 ngx_log_debug(c->log, "http keepalive handler");
1146 1148
1166 if (n == NGX_ERROR) { 1168 if (n == NGX_ERROR) {
1167 ngx_http_close_connection(c); 1169 ngx_http_close_connection(c);
1168 return; 1170 return;
1169 } 1171 }
1170 1172
1171 lctx = (ngx_http_log_ctx_t *) rev->log->data; 1173 ctx = (ngx_http_log_ctx_t *) rev->log->data;
1172 rev->log->handler = NULL; 1174 rev->log->handler = NULL;
1173 1175
1174 if (n == 0) { 1176 if (n == 0) {
1175 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, 1177 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno,
1176 "client %s closed keepalive connection", lctx->client); 1178 "client %s closed keepalive connection", ctx->client);
1177 ngx_http_close_connection(c); 1179 ngx_http_close_connection(c);
1178 return; 1180 return;
1179 } 1181 }
1180 1182
1181 c->buffer->last += n; 1183 c->buffer->last += n;
1182 rev->log->handler = ngx_http_log_error; 1184 rev->log->handler = ngx_http_log_error;
1183 lctx->action = "reading client request line"; 1185 ctx->action = "reading client request line";
1184 1186
1185 ngx_http_init_request(rev); 1187 ngx_http_init_request(rev);
1186 } 1188 }
1187 1189
1188 1190
1304 1306
1305 return; 1307 return;
1306 } 1308 }
1307 1309
1308 1310
1309 static void ngx_http_empty_handler(ngx_event_t *wev) 1311 void ngx_http_empty_handler(ngx_event_t *wev)
1310 { 1312 {
1311 ngx_log_debug(wev->log, "http EMPTY handler"); 1313 ngx_log_debug(wev->log, "http EMPTY handler");
1312 1314
1313 return; 1315 return;
1314 } 1316 }
1440 } 1442 }
1441 1443
1442 1444
1443 static size_t ngx_http_log_error(void *data, char *buf, size_t len) 1445 static size_t ngx_http_log_error(void *data, char *buf, size_t len)
1444 { 1446 {
1445 ngx_http_log_ctx_t *ctx = (ngx_http_log_ctx_t *) data; 1447 ngx_http_log_ctx_t *ctx = data;
1446 1448
1447 if (ctx->action && ctx->url) { 1449 if (ctx->action && ctx->url) {
1448 return ngx_snprintf(buf, len, " while %s, client: %s, URL: %s", 1450 return ngx_snprintf(buf, len, " while %s, client: %s, URL: %s",
1449 ctx->action, ctx->client, ctx->url); 1451 ctx->action, ctx->client, ctx->url);
1450 1452