Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 435:5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 22 Sep 2004 16:18:21 +0000 |
parents | 11362a3e3911 |
children | 9549fc9508e5 |
comparison
equal
deleted
inserted
replaced
434:8998b09f89e9 | 435:5cdc4838d4e8 |
---|---|
10 static void ngx_http_ssl_handshake(ngx_event_t *rev); | 10 static void ngx_http_ssl_handshake(ngx_event_t *rev); |
11 #endif | 11 #endif |
12 static void ngx_http_process_request_line(ngx_event_t *rev); | 12 static void ngx_http_process_request_line(ngx_event_t *rev); |
13 static void ngx_http_process_request_headers(ngx_event_t *rev); | 13 static void ngx_http_process_request_headers(ngx_event_t *rev); |
14 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); | 14 static ssize_t ngx_http_read_request_header(ngx_http_request_t *r); |
15 static ngx_int_t ngx_http_alloc_header_buf(ngx_http_request_t *r, | |
16 ngx_uint_t request_line); | |
15 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); | 17 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r); |
16 | 18 |
17 static void ngx_http_set_write_handler(ngx_http_request_t *r); | 19 static void ngx_http_set_write_handler(ngx_http_request_t *r); |
18 | 20 |
19 static void ngx_http_block_read(ngx_event_t *ev); | 21 static void ngx_http_block_read(ngx_event_t *ev); |
933 | 935 |
934 /* NGX_AGAIN: a header line parsing is still not complete */ | 936 /* NGX_AGAIN: a header line parsing is still not complete */ |
935 | 937 |
936 if (r->header_in->last == r->header_in->end) { | 938 if (r->header_in->last == r->header_in->end) { |
937 | 939 |
940 #if 1 | |
941 /* ngx_http_alloc_large_header_buffer() */ | |
942 | |
943 rc = ngx_http_alloc_header_buf(r, 0); | |
944 | |
945 if (rc == NGX_ERROR) { | |
946 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
947 ngx_http_close_connection(c); | |
948 return; | |
949 } | |
950 | |
951 if (rc == NGX_DECLINED) { | |
952 ngx_http_client_error(r, NGX_HTTP_PARSE_TOO_LONG_HEADER, | |
953 NGX_HTTP_BAD_REQUEST); | |
954 return; | |
955 } | |
956 #endif | |
957 | |
958 #if 0 | |
938 /* | 959 /* |
939 * if the large client headers are enabled then | 960 * if the large client headers are enabled then |
940 * we need to compact r->header_in buf | 961 * we need to compact r->header_in buf |
941 */ | 962 */ |
942 | 963 |
962 } else { | 983 } else { |
963 ngx_http_client_error(r, NGX_HTTP_PARSE_TOO_LONG_HEADER, | 984 ngx_http_client_error(r, NGX_HTTP_PARSE_TOO_LONG_HEADER, |
964 NGX_HTTP_BAD_REQUEST); | 985 NGX_HTTP_BAD_REQUEST); |
965 return; | 986 return; |
966 } | 987 } |
988 #endif | |
967 } | 989 } |
968 } | 990 } |
969 } | 991 } |
970 | 992 |
971 | 993 |
1019 | 1041 |
1020 r->header_in->last += n; | 1042 r->header_in->last += n; |
1021 | 1043 |
1022 return n; | 1044 return n; |
1023 } | 1045 } |
1046 | |
1047 | |
1048 #if 1 | |
1049 | |
1050 static ngx_int_t ngx_http_alloc_header_buf(ngx_http_request_t *r, | |
1051 ngx_uint_t request_line) | |
1052 { | |
1053 u_char *old, *new; | |
1054 ngx_int_t offset; | |
1055 ngx_buf_t *b; | |
1056 ngx_http_connection_t *hc; | |
1057 ngx_http_core_srv_conf_t *cscf; | |
1058 | |
1059 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
1060 "http alloc large header buffer"); | |
1061 | |
1062 old = request_line ? r->request_start : r->header_name_start; | |
1063 | |
1064 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
1065 | |
1066 if ((size_t) (r->header_in->pos - old) >= cscf->client_large_buffers.size) { | |
1067 return NGX_DECLINED; | |
1068 } | |
1069 | |
1070 hc = r->http_connection; | |
1071 | |
1072 if (hc->nfree) { | |
1073 b = hc->free[--hc->nfree]; | |
1074 | |
1075 } else if (hc->nbusy < cscf->client_large_buffers.num) { | |
1076 | |
1077 if (hc->busy == NULL) { | |
1078 hc->busy = ngx_palloc(r->connection->pool, | |
1079 cscf->client_large_buffers.num * sizeof(ngx_buf_t *)); | |
1080 if (hc->busy == NULL) { | |
1081 return NGX_ERROR; | |
1082 } | |
1083 } | |
1084 | |
1085 b = ngx_create_temp_buf(r->connection->pool, | |
1086 cscf->client_large_buffers.size); | |
1087 if (b == NULL) { | |
1088 return NGX_ERROR; | |
1089 } | |
1090 | |
1091 } else { | |
1092 return NGX_DECLINED; | |
1093 } | |
1094 | |
1095 hc->busy[hc->nbusy++] = b; | |
1096 | |
1097 new = b->start; | |
1098 | |
1099 ngx_memcpy(new, old, r->header_in->last - old); | |
1100 | |
1101 b->pos = new + (r->header_in->pos - old); | |
1102 b->last = new + (r->header_in->last - old); | |
1103 | |
1104 if (request_line) { | |
1105 r->request_start = new; | |
1106 r->request_end = new + (r->request_end - old); | |
1107 | |
1108 r->uri_start = new + (r->uri_start - old); | |
1109 r->uri_end = new + (r->uri_end - old); | |
1110 | |
1111 if (r->uri_ext) { | |
1112 r->uri_ext = new + (r->uri_ext - old); | |
1113 } | |
1114 | |
1115 if (r->args_start) { | |
1116 r->args_start = new + (r->args_start - old); | |
1117 } | |
1118 | |
1119 } else { | |
1120 r->header_name_start = new; | |
1121 r->header_name_end = new + (r->header_name_end - old); | |
1122 r->header_start = new + (r->header_start - old); | |
1123 r->header_end = new + (r->header_end - old); | |
1124 } | |
1125 | |
1126 r->header_in = b; | |
1127 | |
1128 return NGX_OK; | |
1129 } | |
1130 | |
1131 #endif | |
1024 | 1132 |
1025 | 1133 |
1026 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) | 1134 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) |
1027 { | 1135 { |
1028 u_char *ua, *user_agent; | 1136 u_char *ua, *user_agent; |