Changeset 341
- Timestamp:
- 08/19/06 17:24:22 (2 years ago)
- Files:
-
- cherokee/branches/0.5/ChangeLog (modified) (1 diff)
- cherokee/branches/0.5/cherokee/buffer.c (modified) (6 diffs)
- cherokee/branches/0.5/cherokee/buffer.h (modified) (2 diffs)
- cherokee/branches/0.5/cherokee/connection.c (modified) (9 diffs)
- cherokee/branches/0.5/cherokee/downloader.c (modified) (1 diff)
- cherokee/branches/0.5/cherokee/handler_admin.c (modified) (2 diffs)
- cherokee/branches/0.5/cherokee/handler_cgi.c (modified) (1 diff)
- cherokee/branches/0.5/cherokee/handler_cgi_base.c (modified) (5 diffs)
- cherokee/branches/0.5/cherokee/handler_error.c (modified) (1 diff)
- cherokee/branches/0.5/cherokee/header-protected.h (modified) (1 diff)
- cherokee/branches/0.5/cherokee/header.c (modified) (16 diffs)
- cherokee/branches/0.5/cherokee/http.h (modified) (2 diffs)
- cherokee/branches/0.5/cherokee/macros.h (modified) (2 diffs)
- cherokee/branches/0.5/cherokee/thread.c (modified) (3 diffs)
- cherokee/branches/0.5/cherokee/unix4win32.c (modified) (1 diff)
- cherokee/branches/0.5/cherokee/validator.c (modified) (2 diffs)
- cherokee/branches/0.5/cherokee/validator_htdigest.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/branches/0.5/ChangeLog
r335 r341 1 2006-08-09 A.D.F <adefacc@tin.it> 2 3 * cherokee/header.c: Now the header parser accepts multi-line 4 values. 5 6 * cherokee/macros.h: Some new macros has been added to replace 7 literal strings like '\r' or '\r\n\r\n'. 8 9 2006-08-18 Alvaro Lopez Ortega <alvaro@alobbs.com> 10 11 * cherokee/buffer.c (cherokee_buffer_add_version): A little clean 12 up. 13 1 14 2006-08-09 A.D.F <adefacc@tin.it> 2 15 cherokee/branches/0.5/cherokee/buffer.c
r234 r341 42 42 43 43 44 #define TO_HEX(c) (c >9? c+'a'-10 : c+'0')44 #define TO_HEX(c) (c > 9 ? c+'a'-10 : c+'0') 45 45 46 46 ret_t … … 259 259 } 260 260 261 return (buf->buf[buf->len - 1] == c);261 return (buf->buf[buf->len - 1] == c); 262 262 } 263 263 … … 266 266 cherokee_buffer_move_to_begin (cherokee_buffer_t *buf, int pos) 267 267 { 268 int offset;269 270 268 if (pos <= 0) 271 269 return ret_ok; … … 274 272 return cherokee_buffer_clean(buf); 275 273 276 offset = MIN(pos, buf->len); 277 memmove (buf->buf, buf->buf+offset, (buf->len - offset) +1); 278 buf->len -= offset; 274 /* At this point: 0 < pos < buf->len 275 */ 276 memmove (buf->buf, buf->buf+pos, (buf->len - pos) + 1); 277 buf->len -= pos; 279 278 280 279 #if 0 … … 631 630 cherokee_buffer_ensure_size (buf, buf->len + 29 + sizeof(PACKAGE_VERSION) + 6 + port_len + 10); 632 631 633 cherokee_buffer_add (buf, "<address>Cherokee web server ", 29); 634 cherokee_buffer_add_str (buf, PACKAGE_VERSION); 635 cherokee_buffer_add (buf, " Port ", 6); 632 cherokee_buffer_add_str (buf, 633 "<address>Cherokee web server " PACKAGE_VERSION " Port "); 636 634 cherokee_buffer_add (buf, port_str, port_len); 637 cherokee_buffer_add (buf, "</address>", 10);635 cherokee_buffer_add_str (buf, "</address>"); 638 636 break; 639 637 … … 641 639 cherokee_buffer_ensure_size (buf, buf->len + 34 + port_len + 10); 642 640 643 cherokee_buffer_add (buf, "<address>Cherokee web server Port ", 34);641 cherokee_buffer_add_str (buf, "<address>Cherokee web server Port "); 644 642 cherokee_buffer_add (buf, port_str, port_len); 645 cherokee_buffer_add (buf, "</address>", 10);643 cherokee_buffer_add_str (buf, "</address>"); 646 644 break; 647 645 cherokee/branches/0.5/cherokee/buffer.h
r122 r341 34 34 #include <stdarg.h> 35 35 #include <stdlib.h> 36 #include <string.h> 36 37 37 38 … … 53 54 54 55 #define cherokee_buffer_is_empty(b) (BUF(b)->len == 0) 55 #define cherokee_buffer_add_str(b,s) cherokee_buffer_add (b, s, sizeof(s)-1)56 #define cherokee_buffer_add_str(b,s) cherokee_buffer_add (b, s, CSZLEN(s)) 56 57 #define cherokee_buffer_cmp_str(b,s) cherokee_buffer_cmp (b, s, sizeof(s)) 57 58 #define cherokee_buffer_case_cmp_str(b,s) cherokee_buffer_case_cmp (b, s, sizeof(s)) 58 59 59 #define cherokee_buffer_cnt_spn(b,o,s) strspn (BUF(b)->buf + (o), (s)) 60 #define cherokee_buffer_cnt_cspn(b,o,s) strcspn (BUF(b)->buf + (o), (s)) 60 61 61 62 cherokee/branches/0.5/cherokee/connection.c
r334 r341 212 212 { 213 213 uint32_t header_len; 214 size_t crlf_len; 214 215 cherokee_server_t *srv = CONN_SRV(cnt); 215 216 … … 286 287 } 287 288 288 /* Drop out the l oast incoming header289 /* Drop out the last incoming header 289 290 */ 290 291 cherokee_header_get_length (&cnt->header, &header_len); … … 293 294 cherokee_buffer_clean (&cnt->buffer); 294 295 cherokee_buffer_clean (&cnt->header_buffer); 296 297 /* Skip trailing CRLF (which may be sent by some HTTP clients) 298 * only if the number of CRLFs is within the predefine count 299 * limit otherwise ignore trailing CRLFs so that they will be 300 * handled in next request. This may avoid a subsequent real 301 * move_to_begin of the contents left in the buffer. 302 */ 303 crlf_len = cherokee_buffer_cnt_spn (&cnt->incoming_header, header_len, CRLF); 304 header_len += (crlf_len <= MAX_HEADER_CRLF) ? crlf_len : 0; 305 295 306 cherokee_buffer_move_to_begin (&cnt->incoming_header, header_len); 296 307 … … 447 458 switch (cnt->header.version) { 448 459 case http_version_09: 460 /* TODO: remove HTTP headers in this version */ 449 461 cherokee_buffer_add_str (buffer, "HTTP/0.9 "); 450 462 break; … … 702 714 */ 703 715 if (cnt->incoming_header.len > MAX_HEADER_LEN) { 704 cnt->error_code = http_request_ uri_too_long;716 cnt->error_code = http_request_entity_too_large; 705 717 return ret_error; 706 718 } … … 961 973 /* ptr = Header at the "Accept-Encoding" position 962 974 */ 963 end = strchr (ptr, '\r');975 end = strchr (ptr, CHR_CR); 964 976 if (end == NULL) { 965 977 return ret_error; … … 1004 1016 } while (i2 < end); 1005 1017 1006 *end = '\r'; /* (1') */1018 *end = CHR_CR; /* (1') */ 1007 1019 return ret_ok; 1008 1020 1009 1021 error: 1010 *end = '\r'; /* (1') */1022 *end = CHR_CR; /* (1') */ 1011 1023 return ret_error; 1012 1024 } … … 1051 1063 /* Skip end of line 1052 1064 */ 1053 end = strchr (ptr, '\r');1054 end2 = strchr (ptr, '\n');1065 end = strchr (ptr, CHR_CR); 1066 end2 = strchr (ptr, CHR_LF); 1055 1067 1056 1068 end = cherokee_min_str (end, end2); … … 1215 1227 /* Maybe there're an ending position 1216 1228 */ 1217 if ((*ptr != '\0') && (*ptr != '\r') && (*ptr != '\n')) {1229 if ((*ptr != '\0') && (*ptr != CHR_CR) && (*ptr != CHR_LF)) { 1218 1230 num_len = 0; 1219 1231 cherokee/branches/0.5/cherokee/downloader.c
r195 r341 332 332 */ 333 333 ret = cherokee_header_has_header (downloader->header, &downloader->reply_header, readed+4); 334 if (ret != ret_ok) { 335 /* It needs to read more header.. 334 switch (ret) { 335 case ret_ok: 336 break; 337 case ret_not_found: 338 /* It needs to read more headers ... 336 339 */ 337 340 return ret_eagain; 341 default: 342 /* Too many initial CRLF 343 */ 344 return ret_error; 338 345 } 339 346 cherokee/branches/0.5/cherokee/handler_admin.c
r332 r341 133 133 134 134 for (tmp = post.buf;;) { 135 char *end1 = strchr (tmp, '\n');136 char *end2 = strchr (tmp, '\r');135 char *end1 = strchr (tmp, CHR_LF); 136 char *end2 = strchr (tmp, CHR_CR); 137 137 char *end = cherokee_min_str (end1, end2); 138 138 … … 143 143 */ 144 144 cherokee_buffer_add (&line, tmp, end - tmp); 145 while ((*end == '\r') || (*end == '\n')) end++;145 while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 146 146 tmp = end; 147 147 cherokee/branches/0.5/cherokee/handler_cgi.c
r332 r341 515 515 switch (errno) { 516 516 case ENOENT: 517 printf ("Status: 404" CRLF CRLF);517 printf ("Status: 404" CRLF_CRLF); 518 518 break; 519 519 default: 520 printf ("Status: 500" CRLF CRLF);520 printf ("Status: 500" CRLF_CRLF); 521 521 } 522 522 cherokee/branches/0.5/cherokee/handler_cgi_base.c
r334 r341 534 534 return ret_ok; 535 535 536 /* It is possible that the header ends with CRLF CRLF536 /* It is possible that the header ends with CRLF_CRLF 537 537 * In this case, we have to remove the last two characters 538 538 */ 539 539 if ((buffer->len > 4) && 540 (strncmp (CRLF CRLF, buffer->buf + buffer->len - 4, 4) == 0))540 (strncmp (CRLF_CRLF, buffer->buf + buffer->len - 4, 4) == 0)) 541 541 { 542 542 cherokee_buffer_drop_endding (buffer, 2); … … 547 547 begin = buffer->buf; 548 548 while (begin != NULL) { 549 end1 = strchr (begin, '\r');550 end2 = strchr (begin, '\n');549 end1 = strchr (begin, CHR_CR); 550 end2 = strchr (begin, CHR_LF); 551 551 552 552 end = cherokee_min_str (end1, end2); … … 554 554 555 555 end2 = end; 556 while (((*end2 == '\r') || (*end2 == '\n')) && (*end2 != '\0')) end2++;556 while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0')) end2++; 557 557 558 558 if (strncasecmp ("Status: ", begin, 8) == 0) { … … 627 627 /* Look the end of headers 628 628 */ 629 content = strstr (inbuf->buf, CRLF CRLF);629 content = strstr (inbuf->buf, CRLF_CRLF); 630 630 if (content != NULL) { 631 631 end_len = 4; 632 632 } else { 633 content = strstr (inbuf->buf, "\n\n");633 content = strstr (inbuf->buf, LF_LF); 634 634 end_len = 2; 635 635 } … … 645 645 cherokee_buffer_ensure_size (outbuf, len+6); 646 646 cherokee_buffer_add (outbuf, inbuf->buf, len); 647 cherokee_buffer_add_str (outbuf, CRLF CRLF);647 cherokee_buffer_add_str (outbuf, CRLF_CRLF); 648 648 649 649 /* Drop out the headers, we already have a copy cherokee/branches/0.5/cherokee/handler_error.c
r258 r341 118 118 cherokee_buffer_add_str (buffer, "You have no access to the request URL"); 119 119 break; 120 case http_request_entity_too_large: 121 cherokee_buffer_add_str (buffer, 122 "The length of request entity exceeds the capacity limit for this server."); 123 break; 120 124 case http_request_uri_too_long: 121 125 cherokee_buffer_add_str (buffer, 122 "The requested URL's lengthexceeds the capacity limit for this server.");126 "The length of requested URL exceeds the capacity limit for this server."); 123 127 break; 124 128 case http_moved_permanently: cherokee/branches/0.5/cherokee/header-protected.h
r240 r341 76 76 cherokee_buffer_t *input_buffer; 77 77 crc_t input_buffer_crc; 78 uint32_t input_header_start; 78 79 uint32_t input_header_len; 79 80 cherokee/branches/0.5/cherokee/header.c
r332 r341 115 115 /* Sanity 116 116 */ 117 hdr->input_buffer = NULL;118 hdr->input_buffer_crc = 0;119 hdr->input_header_len = 0;117 hdr->input_buffer = NULL; 118 hdr->input_buffer_crc = 0; 119 hdr->input_header_len = 0; 120 120 121 121 return ret_ok; … … 208 208 { 209 209 char *line = buf->buf; 210 char *begin = line;210 char *begin = buf->buf; 211 211 char tmp[4]; 212 212 char *end; 213 213 214 end = strchr (line, '\r');214 end = strchr (line, CHR_CR); 215 215 if (end == NULL) { 216 216 return ret_error; … … 223 223 } 224 224 225 /* Return the line endding225 /* Return next line 226 226 */ 227 227 *next_pos = end + 2; … … 363 363 char *ptr; 364 364 char *restore; 365 char chr_end; 365 366 366 367 /* Basic security check. The shortest possible request 367 368 * "GET / HTTP/1.0" is 14 characters long.. 368 369 */ 369 if ( buf->len < 14) {370 if (unlikely(buf->len < 14)) { 370 371 return ret_error; 371 372 } … … 373 374 /* Look for the end of the request line 374 375 */ 375 end = strchr (line, '\r'); 376 if (end == NULL) { 377 return ret_error; 378 } 379 376 end = strchr (line, CHR_LF); 377 if (unlikely(end == NULL || line == end)) { 378 return ret_error; 379 } 380 --end; 381 if (unlikely(*end != CHR_CR)) { 382 ++end; 383 /* Return begin of next line 384 */ 385 *next_pos = end + 1; 386 } else { 387 /* Return begin of next line 388 */ 389 *next_pos = end + 2; 390 } 391 chr_end = *end; 380 392 *end = '\0'; 381 393 restore = end; 382 383 /* Return the line endding384 */385 *next_pos = end + 2;386 394 387 395 /* Get the method … … 454 462 } 455 463 456 *restore = '\r';464 *restore = chr_end; 457 465 return ret_ok; 458 466 459 467 error: 460 *restore = '\r';468 *restore = chr_end; 461 469 return ret_error; 462 470 } … … 467 475 { 468 476 char *end1; 469 char *end2; 470 char *farest; 471 477 char *end2 = string; 478 479 /* RFC states that EOL should be made by CRLF only, but some 480 * old clients (HTTP 0.9 and a few HTTP/1.0 robots) may send 481 * LF only as EOL, so try to catch that case too (of course CR 482 * only is ignored); anyway leading spaces after a LF or CRLF 483 * means that the new line is the continuation of previous 484 * line (first line excluded). 485 */ 472 486 do { 473 end1 = strchr (string, '\r'); 474 end2 = strchr (string, '\n'); 475 476 farest = cherokee_min_str (end1, end2); 477 if (farest == NULL) return NULL; 478 479 string = farest+1; 480 } while (farest[1] == ' '); 481 482 return farest; 483 } 484 485 ret_t 486 cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_type_header_t type) 487 end1 = end2; 488 end2 = strchr (end1, CHR_LF); 489 490 if (unlikely (end2 == NULL)) 491 return NULL; 492 493 end1 = end2; 494 if (likely (end2 != string && *(end1 - 1) == CHR_CR)) 495 --end1; 496 497 ++end2; 498 } while (*end2 == CHR_SP || *end2 == CHR_HT); 499 500 return end1; 501 } 502 503 504 ret_t 505 cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_type_header_t type) 487 506 { 488 507 ret_t ret; … … 491 510 char *colon; 492 511 char *header_end; 512 char chr_header_end; 493 513 494 514 /* Check the buffer content 495 515 */ 496 516 if ((buffer->buf == NULL) || (buffer->len < 5)) { 497 PRINT_ERROR_S ("ERROR: Calling cherokee_header_parse() with a empty header\n");517 PRINT_ERROR_S ("ERROR: Calling cherokee_header_parse() with an empty header\n"); 498 518 return ret_error; 499 519 } … … 507 527 #endif 508 528 509 /* Look for the header endding 'CRLF CRLF' 510 */ 511 header_end = strstr (buffer->buf, CRLF CRLF); 512 if (header_end == NULL) { 513 PRINT_ERROR ("ERROR: Cannot find the end of the header:\n===\n%s===\n", buffer->buf); 514 return ret_error; 515 } 516 517 header_end += 4; 518 hdr->input_header_len = (header_end - buffer->buf); 519 520 /* Parse the speacial first line 529 /* header_len should have already been set by a previous call 530 * to cherokee_header_has_header() but if not we call it now. 531 */ 532 if (unlikely (hdr->input_header_len < 1)) { 533 /* Strange, anyway go on and look for EOH 534 */ 535 ret = cherokee_header_has_header(hdr, buffer, buffer->len); 536 if (ret != ret_ok) { 537 if (ret == ret_not_found) 538 PRINT_ERROR("ERROR: EOH not found:\n===\n%s===\n", buffer->buf); 539 else 540 PRINT_ERROR("ERROR: Too many initial CRLF:\n===\n%s===\n", buffer->buf); 541 return ret_error; 542 } 543 } 544 header_end = &(buffer->buf[hdr->input_header_len]); 545 546 /* Terminate current request space (there maybe other 547 * pipelined requests in the buffer) after the EOH. 548 */ 549 chr_header_end = *header_end; 550 *header_end = '\0'; 551 552 /* Parse the special first line 521 553 */ 522 554 switch (type) { 523 555 case header_type_request: 524 556 /* Parse request. Something like this: 525 * GET /icons/compressed.png HTTP/1.1 \r\n557 * GET /icons/compressed.png HTTP/1.1CRLF 526 558 */ 527 559 ret = parse_request_first_line (hdr, buffer, &begin); 528 560 if (unlikely(ret < ret_ok)) { 529 561 PRINT_DEBUG ("ERROR: Failed to parse header_type_request:\n===\n%s===\n", buffer->buf); 562 *header_end = chr_header_end; 530 563 return ret; 531 564 } … … 536 569 if (unlikely(ret < ret_ok)) { 537 570 PRINT_DEBUG ("ERROR: Failed to parse header_type_response:\n===\n%s===\n", buffer->buf); 571 *header_end = chr_header_end; 538 572 return ret; 539 573 } … … 546 580 547 581 default: 582 *header_end = chr_header_end; 548 583 SHOULDNT_HAPPEN; 549 584 } … … 552 587 /* Parse the rest of headers 553 588 */ 554 while (( end = get_new_line(begin)) && (end < header_end))555 { 589 while ((begin < header_end) && (end = get_new_line(begin)) != NULL) 590 { 556 591 cuint_t header_len; 557 592 char first_char; 558 char end_char= *end;593 char chr_end = *end; 559 594 560 595 *end = '\0'; 561 596 597 /* Current line may have embedded CR+SP or CRLF+SP 598 */ 562 599 colon = strchr (begin, ':'); 563 600 if (colon == NULL) { … … 565 602 } 566 603 567 if (end < colon + 2) {604 if (end < colon + 2) { 568 605 goto next; 569 606 } … … 650 687 if (ret < ret_ok) { 651 688 PRINT_ERROR_S ("ERROR: Failed to add_(un)known_header()\n"); 689 *header_end = chr_header_end; 652 690 return ret; 653 691 } 654 692 655 693 next: 656 *end = end_char;657 658 while ((*end == '\r') || (*end == '\n')) end++;694 *end = chr_end; 695 696 while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 659 697 begin = end; 660 698 } 661 699 700 *header_end = chr_header_end; 662 701 return ret_ok; 663 702 } … … 859 898 /* Known headers 860 899 */ 861 for (i=0; i<HEADER_LENGTH; i++) 862 { 900 for (i=0; i<HEADER_LENGTH; i++) { 863 901 if (hdr->header[i].info_off != 0) { 864 902 num++; … … 876 914 cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, int tail_len) 877 915 { 878 int tail; 879 char *start; 880 881 /* Too few information? 882 * len("GET / HTTP/1.0" CRLF CRLF) = 18 883 */ 884 if (buffer->len < 18) { 885 return ret_deny; 916 char *start; 917 char *end; 918 size_t crlf_len = 0; 919 920 /* Skip initial CRLFs: 921 * NOTE: they are not allowed by standard (RFC) but many 922 * popular HTTP clients (including MSIE, etc.) may send a 923 * couple of them between two requests, so every widely used 924 * web server has to deal with them. 925 */ 926 crlf_len = cherokee_buffer_cnt_spn (buffer, 0, CRLF); 927 if (unlikely (crlf_len > MAX_HEADER_CRLF)) { 928 /* Too many initial CRLF 929 */ 930 return ret_error; 931 } 932 933 if (unlikely (tail_len < 0)) { 934 /* Bad parameter value 935 */ 936 return ret_error; 937 } 938 939 if ((crlf_len > 0) && (crlf_len < (size_t) buffer->len)) { 940 /* Found heading CRLFs and their length is less than 941 * buffer length so we have to move the real content 942 * to the beginning of the buffer. 943 */ 944 cherokee_buffer_move_to_begin(buffer, (int) crlf_len); 945 } 946 947 /* Do we have enough information ? 948 * len("GET /" CRLF_CRLF) = 9 (HTTP/0.9) 949 * len("GET / HTTP/1.0" CRLF_CRLF) = 18 (HTTP/1.x) 950 */ 951 if (unlikely (buffer->len < 18)) { 952 return ret_not_found; 886 953 } 887 954 888 955 /* Look for the starting point 889 956 */ 890 tail = (tail_len < buffer->len) ? tail_len : buffer->len;891 start = buffer->buf + (buffer->len - tail);957 start = (tail_len >= buffer->len) ? 958 buffer->buf : buffer->buf + (buffer->len - tail_len); 892 959 893 960 /* It could be a partial header, or maybe a POST request 894 961 */ 895 return (strstr(start, CRLF CRLF) != NULL) ? ret_ok : ret_error; 896 } 962 if (unlikely((end = strstr(start, CRLF_CRLF)) == NULL)) { 963 if ((end = strstr(start, LF_LF)) == NULL) 964 return ret_not_found; 965 966 /* Found uncommon / non standard EOH, set header length 967 */ 968 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(LF_LF); 969 return ret_ok; 970 } 971 972 /* Found standard EOH, set header length 973 */ 974 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(CRLF_CRLF); 975 976 return ret_ok; 977 } cherokee/branches/0.5/cherokee/http.h
r284 r341 83 83 84 84 typedef enum { 85 http_unset = 0, 86 http_continue = 100, 87 http_switching_protocols = 101, 88 http_ok = 200, 89 http_accepted = 202, 90 http_partial_content = 206, 91 http_moved_permanently = 301, 92 http_moved_temporarily = 302, 93 http_see_other = 303, 94 http_not_modified = 304, 95 http_bad_request = 400, 96 http_unauthorized = 401, 97 http_access_denied = 403, 98 http_not_found = 404, 99 http_method_not_allowed = 405, 100 http_length_required = 411, 101 http_request_uri_too_long = 414, 102 http_range_not_satisfiable = 416, 103 http_upgrade_required = 426, 104 http_internal_error = 500, 105 http_service_unavailable = 503 85 http_unset = 0, 86 http_continue = 100, 87 http_switching_protocols = 101, 88 http_ok = 200, 89 http_accepted = 202, 90 http_partial_content = 206, 91 http_moved_permanently = 301, 92 http_moved_temporarily = 302, 93 http_see_other = 303, 94 http_not_modified = 304, 95 http_bad_request = 400, 96 http_unauthorized = 401, 97 http_access_denied = 403, 98 http_not_found = 404, 99 http_method_not_allowed = 405, 100 http_length_required = 411, 101 http_request_entity_too_large = 413, 102 http_request_uri_too_long = 414, 103 http_range_not_satisfiable = 416, 104 http_upgrade_required = 426, 105 http_internal_error = 500, 106 http_service_unavailable = 503 106 107 } cherokee_http_t; 107 108 … … 123 124 #define http_method_not_allowed_string "405 Method Not Allowed" 124 125 #define http_length_required_string "411 Length Required" 126 #define http_request_entity_too_large_string "413 Request Entity too large" 125 127 #define http_request_uri_too_long_string "414 Request-URI too long" 126 128 #define http_range_not_satisfiable_string "416 Requested range not satisfiable" cherokee/branches/0.5/cherokee/macros.h
r332 r341 82 82 #define DEFAULT_READ_SIZE 8192 83 83 #define MAX_HEADER_LEN 4096 84 #define MAX_HEADER_CRLF 8 84 85 #define MAX_KEEPALIVE 500 85 86 #define MAX_NEW_CONNECTIONS_PER_STEP 50 … … 100 101 #define EXIT_SERVER_INIT 32 101 102 102 #define CRLF "\r\n" 103 104 #define CSZLEN(str) (sizeof(str) - 1) 105 106 #define LF_LF "\n\n" /* EOHs (End Of Headers) */ 107 #define CRLF_CRLF "\r\n\r\n" /* EOHs (End Of Headers) */ 108 #define CRLF "\r\n" /* EOH (End Of Header Line) */ 109 #define LWS " \t\r\n" /* HTTP linear white space */ 110 #define CHR_CR '\r' /* carriage return */ 111 #define CHR_LF '\n' /* line feed (new line) */ 112 #define CHR_SP ' ' /* space */ 113 #define CHR_HT '\t' /* horizontal tab */ 103 114 104 115 #define return_if_fail(expr,ret) \ cherokee/branches/0.5/cherokee/thread.c
r321 r341 686 686 goto phase_reading_header_EXIT; 687 687 } 688 } 689 688 if (ret != ret_not_found) { 689 /* Too many initial CRLF */ 690 purge_closed_connection (thd, conn); 691 continue; 692 } 693 } 694 690 695 /* Read from the client 691 696 */ … … 721 726 continue; 722 727 } 728 /* fall down */ 723 729 724 730 phase_reading_header_EXIT: 725 731 conn->phase = phase_processing_header; 732 /* fall down */ 726 733 727 734 case phase_processing_header: … … 755 762 756 763 conn->phase = phase_setup_connection; 764 /* fall down */ 757 765 758 766 case phase_setup_connection: { cherokee/branches/0.5/cherokee/unix4win32.c
r122 r341 104 104 if (ptr == NULL) return NULL; 105 105 106 len = strcspn (ptr, " \ n\t\n\r");106 len = strcspn (ptr, " \t\n\r"); 107 107 108 108 if (!(entry = (char *) malloc (len + 1))) { cherokee/branches/0.5/cherokee/validator.c
r220 r341 163 163 /* Skip some chars 164 164 */ 165 while ((*entry == ' ') ||166 (*entry == '\r') ||167 (*entry == '\n')) entry++;165 while ((*entry == CHR_SP) || 166 (*entry == CHR_CR) || 167 (*entry == CHR_LF)) entry++; 168 168 169 169 /* Check for the end … … 213 213 while ((len > 0) && 214 214 ((equal[len-1] == '"') || 215 (equal[len-1] == '\r') ||216 (equal[len-1] == '\n'))) len--;215 (equal[len-1] == CHR_CR) || 216 (equal[len-1] == CHR_LF))) len--; 217 217 218 218 /* Copy the entry value cherokee/branches/0.5/cherokee/validator_htdigest.c
r332 r341 121 121 */ 122 122 pos = eol; 123 while ((*pos == '\r') || (*pos == '\n')) pos++;123 while ((*pos == CHR_CR) || (*pos == CHR_LF)) pos++; 124 124 } 125 125