comparison src/http/ngx_http_request.c @ 4739:986cc869b09d

Corrected $request_length calculation for pipelined requests.
author Andrey Belov <defan@nginx.com>
date Fri, 06 Jul 2012 04:27:06 +0000
parents 09187f9b0950
children 5b93a9ac60ed
comparison
equal deleted inserted replaced
4738:512c741fa841 4739:986cc869b09d
745 745
746 /* the request line has been parsed successfully */ 746 /* the request line has been parsed successfully */
747 747
748 r->request_line.len = r->request_end - r->request_start; 748 r->request_line.len = r->request_end - r->request_start;
749 r->request_line.data = r->request_start; 749 r->request_line.data = r->request_start;
750 r->request_length = r->header_in->pos - r->request_start;
750 751
751 752
752 if (r->args_start) { 753 if (r->args_start) {
753 r->uri.len = r->args_start - 1 - r->uri_start; 754 r->uri.len = r->args_start - 1 - r->uri_start;
754 } else { 755 } else {
1054 rc = ngx_http_parse_header_line(r, r->header_in, 1055 rc = ngx_http_parse_header_line(r, r->header_in,
1055 cscf->underscores_in_headers); 1056 cscf->underscores_in_headers);
1056 1057
1057 if (rc == NGX_OK) { 1058 if (rc == NGX_OK) {
1058 1059
1060 r->request_length += r->header_in->pos - r->header_name_start;
1061
1059 if (r->invalid_header && cscf->ignore_invalid_headers) { 1062 if (r->invalid_header && cscf->ignore_invalid_headers) {
1060 1063
1061 /* there was error while a header line parsing */ 1064 /* there was error while a header line parsing */
1062 1065
1063 ngx_log_error(NGX_LOG_INFO, c->log, 0, 1066 ngx_log_error(NGX_LOG_INFO, c->log, 0,
1117 /* a whole header has been parsed successfully */ 1120 /* a whole header has been parsed successfully */
1118 1121
1119 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1122 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1120 "http header done"); 1123 "http header done");
1121 1124
1122 r->request_length += r->header_in->pos - r->header_in->start; 1125 r->request_length += r->header_in->pos - r->header_name_start;
1123 1126
1124 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; 1127 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE;
1125 1128
1126 rc = ngx_http_process_request_header(r); 1129 rc = ngx_http_process_request_header(r);
1127 1130
1223 "http alloc large header buffer"); 1226 "http alloc large header buffer");
1224 1227
1225 if (request_line && r->state == 0) { 1228 if (request_line && r->state == 0) {
1226 1229
1227 /* the client fills up the buffer with "\r\n" */ 1230 /* the client fills up the buffer with "\r\n" */
1228
1229 r->request_length += r->header_in->end - r->header_in->start;
1230 1231
1231 r->header_in->pos = r->header_in->start; 1232 r->header_in->pos = r->header_in->start;
1232 r->header_in->last = r->header_in->start; 1233 r->header_in->last = r->header_in->start;
1233 1234
1234 return NGX_OK; 1235 return NGX_OK;
1285 * r->state == 0 means that a header line was parsed successfully 1286 * r->state == 0 means that a header line was parsed successfully
1286 * and we do not need to copy incomplete header line and 1287 * and we do not need to copy incomplete header line and
1287 * to relocate the parser header pointers 1288 * to relocate the parser header pointers
1288 */ 1289 */
1289 1290
1290 r->request_length += r->header_in->end - r->header_in->start;
1291
1292 r->header_in = b; 1291 r->header_in = b;
1293 1292
1294 return NGX_OK; 1293 return NGX_OK;
1295 } 1294 }
1296 1295
1297 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1296 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1298 "http large header copy: %d", r->header_in->pos - old); 1297 "http large header copy: %d", r->header_in->pos - old);
1299
1300 r->request_length += old - r->header_in->start;
1301 1298
1302 new = b->start; 1299 new = b->start;
1303 1300
1304 ngx_memcpy(new, old, r->header_in->pos - old); 1301 ngx_memcpy(new, old, r->header_in->pos - old);
1305 1302