comparison src/http/ngx_http_parse.c @ 18:72ad26c77d2d

nginx-0.0.1-2002-10-04-21:58:04 import
author Igor Sysoev <igor@sysoev.ru>
date Fri, 04 Oct 2002 17:58:04 +0000
parents 055ed05235ae
children df7fb216a149
comparison
equal deleted inserted replaced
17:8dd06e2844f5 18:72ad26c77d2d
30 /* 30 /*
31 printf("\nstate: %d, pos: %x, end: %x, char: '%c' buf: %s", 31 printf("\nstate: %d, pos: %x, end: %x, char: '%c' buf: %s",
32 state, p, r->header_in->last, ch, p); 32 state, p, r->header_in->last, ch, p);
33 */ 33 */
34 34
35 /* GCC 2.95.2 and VC 6.0 compiles this switch as jump table */ 35 /* GCC 2.95.2 and VC 6.0 compile this switch as jump table */
36 36
37 switch (state) { 37 switch (state) {
38 38
39 /* HTTP methods: GET, HEAD, POST */ 39 /* HTTP methods: GET, HEAD, POST */
40 case sw_start: 40 case sw_start:
255 case sw_first_minor_digit: 255 case sw_first_minor_digit:
256 if (ch < '0' || ch > '9') 256 if (ch < '0' || ch > '9')
257 return NGX_HTTP_PARSE_INVALID_REQUEST; 257 return NGX_HTTP_PARSE_INVALID_REQUEST;
258 258
259 r->http_minor = ch - '0'; 259 r->http_minor = ch - '0';
260
261 state = sw_minor_digit; 260 state = sw_minor_digit;
262 break; 261 break;
263 262
264 /* minor HTTP version or end of request line */ 263 /* minor HTTP version or end of request line */
265 case sw_minor_digit: 264 case sw_minor_digit:
279 r->http_minor = r->http_minor * 10 + ch - '0'; 278 r->http_minor = r->http_minor * 10 + ch - '0';
280 break; 279 break;
281 280
282 /* end of request line */ 281 /* end of request line */
283 case sw_almost_done: 282 case sw_almost_done:
283 r->request_end = p - 2;
284 switch (ch) { 284 switch (ch) {
285 case LF: 285 case LF:
286 state = sw_done; 286 state = sw_done;
287 break; 287 break;
288 default: 288 default:
293 } 293 }
294 294
295 r->header_in->pos.mem = p; 295 r->header_in->pos.mem = p;
296 296
297 if (state == sw_done) { 297 if (state == sw_done) {
298 if (r->request_end == NULL)
299 r->request_end = p - 1;
298 r->http_version = r->http_major * 1000 + r->http_minor; 300 r->http_version = r->http_major * 1000 + r->http_minor;
299 r->state = sw_start; 301 r->state = sw_start;
300 if (r->http_version == 9 && r->method == NGX_HTTP_HEAD) 302 if (r->http_version == 9 && r->method == NGX_HTTP_HEAD)
301 return NGX_HTTP_PARSE_INVALID_HEAD; 303 return NGX_HTTP_PARSE_INVALID_HEAD;
302 else 304 else