Changeset 342
- Timestamp:
- 08/20/06 13:50:26 (2 years ago)
- Files:
-
- cherokee/trunk/cherokee/buffer.c (modified) (6 diffs)
- cherokee/trunk/cherokee/buffer.h (modified) (2 diffs)
- cherokee/trunk/cherokee/connection.c (modified) (9 diffs)
- cherokee/trunk/cherokee/downloader.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_admin.c (modified) (2 diffs)
- cherokee/trunk/cherokee/handler_cgi.c (modified) (1 diff)
- cherokee/trunk/cherokee/handler_cgi_base.c (modified) (5 diffs)
- cherokee/trunk/cherokee/handler_error.c (modified) (1 diff)
- cherokee/trunk/cherokee/header-protected.h (modified) (1 diff)
- cherokee/trunk/cherokee/header.c (modified) (17 diffs)
- cherokee/trunk/cherokee/http.h (modified) (1 diff)
- cherokee/trunk/cherokee/macros.h (modified) (2 diffs)
- cherokee/trunk/cherokee/thread.c (modified) (3 diffs)
- cherokee/trunk/cherokee/unix4win32.c (modified) (1 diff)
- cherokee/trunk/cherokee/validator.c (modified) (2 diffs)
- cherokee/trunk/cherokee/validator_htdigest.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cherokee/trunk/cherokee/buffer.c
r269 r342 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 … … 275 275 } 276 276 277 return (buf->buf[buf->len - 1] == c);277 return (buf->buf[buf->len - 1] == c); 278 278 } 279 279 … … 282 282 cherokee_buffer_move_to_begin (cherokee_buffer_t *buf, int pos) 283 283 { 284 int offset;285 286 284 if (pos <= 0) 287 285 return ret_ok; … … 290 288 return cherokee_buffer_clean(buf); 291 289 292 offset = MIN(pos, buf->len); 293 memmove (buf->buf, buf->buf+offset, (buf->len - offset) +1); 294 buf->len -= offset; 290 /* At this point: 0 < pos < buf->len 291 */ 292 memmove (buf->buf, buf->buf+pos, (buf->len - pos) + 1); 293 buf->len -= pos; 295 294 296 295 #if 0 … … 647 646 cherokee_buffer_ensure_size (buf, buf->len + 29 + sizeof(PACKAGE_VERSION) + 6 + port_len + 10); 648 647 649 cherokee_buffer_add (buf, "<address>Cherokee web server ", 29); 650 cherokee_buffer_add_str (buf, PACKAGE_VERSION); 651 cherokee_buffer_add (buf, " Port ", 6); 648 cherokee_buffer_add_str (buf, 649 "<address>Cherokee web server " PACKAGE_VERSION " Port "); 652 650 cherokee_buffer_add (buf, port_str, port_len); 653 cherokee_buffer_add (buf, "</address>", 10);651 cherokee_buffer_add_str (buf, "</address>"); 654 652 break; 655 653 … … 657 655 cherokee_buffer_ensure_size (buf, buf->len + 34 + port_len + 10); 658 656 659 cherokee_buffer_add (buf, "<address>Cherokee web server Port ", 34);657 cherokee_buffer_add_str (buf, "<address>Cherokee web server Port "); 660 658 cherokee_buffer_add (buf, port_str, port_len); 661 cherokee_buffer_add (buf, "</address>", 10);659 cherokee_buffer_add_str (buf, "</address>"); 662 660 break; 663 661 cherokee/trunk/cherokee/buffer.h
r269 r342 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)) 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)) 58 61 59 62 cherokee/trunk/cherokee/connection.c
r336 r342 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 … … 446 457 switch (cnt->header.version) { 447 458 case http_version_09: 459 /* TODO: remove HTTP headers in this version */ 448 460 cherokee_buffer_add_str (buffer, "HTTP/0.9 "); 449 461 break; … … 703 715 */ 704 716 if (cnt->incoming_header.len > MAX_HEADER_LEN) { 705 cnt->error_code = http_request_ uri_too_long;717 cnt->error_code = http_request_entity_too_large; 706 718 return ret_error; 707 719 } … … 962 974 /* ptr = Header at the "Accept-Encoding" position 963 975 */ 964 end = strchr (ptr, '\r');976 end = strchr (ptr, CHR_CR); 965 977 if (end == NULL) { 966 978 return ret_error; … … 1005 1017 } while (i2 < end); 1006 1018 1007 *end = '\r'; /* (1') */1019 *end = CHR_CR; /* (1') */ 1008 1020 return ret_ok; 1009 1021 1010 1022 error: 1011 *end = '\r'; /* (1') */1023 *end = CHR_CR; /* (1') */ 1012 1024 return ret_error; 1013 1025 } … … 1052 1064 /* Skip end of line 1053 1065 */ 1054 end = strchr (ptr, '\r');1055 end2 = strchr (ptr, '\n');1066 end = strchr (ptr, CHR_CR); 1067 end2 = strchr (ptr, CHR_LF); 1056 1068 1057 1069 end = cherokee_min_str (end, end2); … … 1216 1228 /* Maybe there're an ending position 1217 1229 */ 1218 if ((*ptr != '\0') && (*ptr != '\r') && (*ptr != '\n')) {1230 if ((*ptr != '\0') && (*ptr != CHR_CR) && (*ptr != CHR_LF)) { 1219 1231 num_len = 0; 1220 1232 cherokee/trunk/cherokee/downloader.c
r336 r342 281 281 */ 282 282 ret = cherokee_header_has_header (downloader->header, &downloader->reply_header, readed+4); 283 if (ret != ret_ok) { 284 /* It needs to read more header.. 283 switch (ret) { 284 case ret_ok: 285 break; 286 case ret_not_found: 287 /* It needs to read more headers ... 285 288 */ 286 289 return ret_eagain; 290 default: 291 /* Too many initial CRLF 292 */ 293 return ret_error; 287 294 } 288 295 cherokee/trunk/cherokee/handler_admin.c
r333 r342 138 138 139 139 for (tmp = post.buf;;) { 140 char *end1 = strchr (tmp, '\n');141 char *end2 = strchr (tmp, '\r');140 char *end1 = strchr (tmp, CHR_LF); 141 char *end2 = strchr (tmp, CHR_CR); 142 142 char *end = cherokee_min_str (end1, end2); 143 143 … … 148 148 */ 149 149 cherokee_buffer_add (&line, tmp, end - tmp); 150 while ((*end == '\r') || (*end == '\n')) end++;150 while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 151 151 tmp = end; 152 152 cherokee/trunk/cherokee/handler_cgi.c
r333 r342 541 541 switch (errno) { 542 542 case ENOENT: 543 printf ("Status: 404" CRLF CRLF);543 printf ("Status: 404" CRLF_CRLF); 544 544 break; 545 545 default: 546 printf ("Status: 500" CRLF CRLF);546 printf ("Status: 500" CRLF_CRLF); 547 547 } 548 548 cherokee/trunk/cherokee/handler_cgi_base.c
r336 r342 621 621 return ret_ok; 622 622 623 /* It is possible that the header ends with CRLF CRLF623 /* It is possible that the header ends with CRLF_CRLF 624 624 * In this case, we have to remove the last two characters 625 625 */ 626 626 if ((buffer->len > 4) && 627 (strncmp (CRLF CRLF, buffer->buf + buffer->len - 4, 4) == 0))627 (strncmp (CRLF_CRLF, buffer->buf + buffer->len - 4, 4) == 0)) 628 628 { 629 629 cherokee_buffer_drop_endding (buffer, 2); … … 634 634 begin = buffer->buf; 635 635 while (begin != NULL) { 636 end1 = strchr (begin, '\r');637 end2 = strchr (begin, '\n');636 end1 = strchr (begin, CHR_CR); 637 end2 = strchr (begin, CHR_LF); 638 638 639 639 end = cherokee_min_str (end1, end2); … … 641 641 642 642 end2 = end; 643 while (((*end2 == '\r') || (*end2 == '\n')) && (*end2 != '\0')) end2++;643 while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0')) end2++; 644 644 645 645 if (strncasecmp ("Status: ", begin, 8) == 0) { … … 714 714 /* Look the end of headers 715 715 */ 716 content = strstr (inbuf->buf, CRLF CRLF);716 content = strstr (inbuf->buf, CRLF_CRLF); 717 717 if (content != NULL) { 718 718 end_len = 4; 719 719 } else { 720 content = strstr (inbuf->buf, "\n\n");720 content = strstr (inbuf->buf, LF_LF); 721 721 end_len = 2; 722 722 } … … 732 732 cherokee_buffer_ensure_size (outbuf, len+6); 733 733 cherokee_buffer_add (outbuf, inbuf->buf, len); 734 cherokee_buffer_add_str (outbuf, CRLF CRLF);734 cherokee_buffer_add_str (outbuf, CRLF_CRLF); 735 735 736 736 /* Drop out the headers, we already have a copy cherokee/trunk/cherokee/handler_error.c
r282 r342 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/trunk/cherokee/header-protected.h
r240 r342 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/trunk/cherokee/header.c
r333 r342 59 59 int i; 60 60 61 for (i=0; i<HEADER_LENGTH; i++) 62 { 61 for (i=0; i<HEADER_LENGTH; i++) { 63 62 hdr->header[i].info_off = 0; 64 63 hdr->header[i].info_len = -1; … … 115 114 /* Sanity 116 115 */ 117 hdr->input_buffer = NULL;118 hdr->input_buffer_crc = 0;119 hdr->input_header_len = 0;116 hdr->input_buffer = NULL; 117 hdr->input_buffer_crc = 0; 118 hdr->input_header_len = 0; 120 119 121 120 return ret_ok; … … 208 207 { 209 208 char *line = buf->buf; 210 char *begin = line;209 char *begin = buf->buf; 211 210 char tmp[4]; 212 211 char *end; 213 212 214 end = strchr (line, '\r');213 end = strchr (line, CHR_CR); 215 214 if (end == NULL) { 216 215 return ret_error; … … 223 222 } 224 223 225 /* Return the line endding224 /* Return next line 226 225 */ 227 226 *next_pos = end + 2; … … 363 362 char *ptr; 364 363 char *restore; 364 char chr_end; 365 365 366 366 /* Basic security check. The shortest possible request 367 367 * "GET / HTTP/1.0" is 14 characters long.. 368 368 */ 369 if ( buf->len < 14) {369 if (unlikely(buf->len < 14)) { 370 370 return ret_error; 371 371 } … … 373 373 /* Look for the end of the request line 374 374 */ 375 end = strchr (line, '\r'); 376 if (end == NULL) { 377 return ret_error; 378 } 379 375 end = strchr (line, CHR_LF); 376 if (unlikely(end == NULL || line == end)) { 377 return ret_error; 378 } 379 --end; 380 if (unlikely(*end != CHR_CR)) { 381 ++end; 382 /* Return begin of next line 383 */ 384 *next_pos = end + 1; 385 } else { 386 /* Return begin of next line 387 */ 388 *next_pos = end + 2; 389 } 390 chr_end = *end; 380 391 *end = '\0'; 381 392 restore = end; 382 383 /* Return the line endding384 */385 *next_pos = end + 2;386 393 387 394 /* Get the method … … 454 461 } 455 462 456 *restore = '\r';463 *restore = chr_end; 457 464 return ret_ok; 458 465 459 466 error: 460 *restore = '\r';467 *restore = chr_end; 461 468 return ret_error; 462 469 } … … 467 474 { 468 475 char *end1; 469 char *end2; 470 char *farest; 471 476 char *end2 = string; 477 478 /* RFC states that EOL should be made by CRLF only, but some 479 * old clients (HTTP 0.9 and a few HTTP/1.0 robots) may send 480 * LF only as EOL, so try to catch that case too (of course CR 481 * only is ignored); anyway leading spaces after a LF or CRLF 482 * means that the new line is the continuation of previous 483 * line (first line excluded). 484 */ 472 485 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) 486 end1 = end2; 487 end2 = strchr (end1, CHR_LF); 488 489 if (unlikely (end2 == NULL)) 490 return NULL; 491 492 end1 = end2; 493 if (likely (end2 != string && *(end1 - 1) == CHR_CR)) 494 --end1; 495 496 ++end2; 497 } while (*end2 == CHR_SP || *end2 == CHR_HT); 498 499 return end1; 500 } 501 502 503 ret_t 504 cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_type_header_t type) 487 505 { 488 506 ret_t ret; … … 491 509 char *colon; 492 510 char *header_end; 511 char chr_header_end; 493 512 494 513 /* Check the buffer content 495 514 */ 496 515 if ((buffer->buf == NULL) || (buffer->len < 5)) { 497 PRINT_ERROR_S ("ERROR: Calling cherokee_header_parse() with a empty header\n");516 PRINT_ERROR_S ("ERROR: Calling cherokee_header_parse() with an empty header\n"); 498 517 return ret_error; 499 518 } … … 507 526 #endif 508 527 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 528 /* header_len should have already been set by a previous call 529 * to cherokee_header_has_header() but if not we call it now. 530 */ 531 if (unlikely (hdr->input_header_len < 1)) { 532 /* Strange, anyway go on and look for EOH 533 */ 534 ret = cherokee_header_has_header(hdr, buffer, buffer->len); 535 if (ret != ret_ok) { 536 if (ret == ret_not_found) 537 PRINT_ERROR("ERROR: EOH not found:\n===\n%s===\n", buffer->buf); 538 else 539 PRINT_ERROR("ERROR: Too many initial CRLF:\n===\n%s===\n", buffer->buf); 540 return ret_error; 541 } 542 } 543 header_end = &(buffer->buf[hdr->input_header_len]); 544 545 /* Terminate current request space (there maybe other 546 * pipelined requests in the buffer) after the EOH. 547 */ 548 chr_header_end = *header_end; 549 *header_end = '\0'; 550 551 /* Parse the special first line 521 552 */ 522 553 switch (type) { 523 554 case header_type_request: 524 555 /* Parse request. Something like this: 525 * GET /icons/compressed.png HTTP/1.1 \r\n556 * GET /icons/compressed.png HTTP/1.1CRLF 526 557 */ 527 558 ret = parse_request_first_line (hdr, buffer, &begin); 528 559 if (unlikely(ret < ret_ok)) { 529 560 PRINT_DEBUG ("ERROR: Failed to parse header_type_request:\n===\n%s===\n", buffer->buf); 561 *header_end = chr_header_end; 530 562 return ret; 531 563 } … … 536 568 if (unlikely(ret < ret_ok)) { 537 569 PRINT_DEBUG ("ERROR: Failed to parse header_type_response:\n===\n%s===\n", buffer->buf); 570 *header_end = chr_header_end; 538 571 return ret; 539 572 } … … 546 579 547 580 default: 581 *header_end = chr_header_end; 548 582 SHOULDNT_HAPPEN; 549 583 } … … 552 586 /* Parse the rest of headers 553 587 */ 554 while (( end = get_new_line(begin)) && (end < header_end))555 { 588 while ((begin < header_end) && (end = get_new_line(begin)) != NULL) 589 { 556 590 cuint_t header_len; 557 591 char first_char; 558 char end_char= *end;592 char chr_end = *end; 559 593 560 594 *end = '\0'; 561 595 596 /* Current line may have embedded CR+SP or CRLF+SP 597 */ 562 598 colon = strchr (begin, ':'); 563 599 if (colon == NULL) { … … 565 601 } 566 602 567 if (end < colon + 2) {603 if (end < colon + 2) { 568 604 goto next; 569 605 } … … 650 686 if (ret < ret_ok) { 651 687 PRINT_ERROR_S ("ERROR: Failed to add_(un)known_header()\n"); 688 *header_end = chr_header_end; 652 689 return ret; 653 690 } 654 691 655 692 next: 656 *end = end_char;657 658 while ((*end == '\r') || (*end == '\n')) end++;693 *end = chr_end; 694 695 while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 659 696 begin = end; 660 697 } 661 698 699 *header_end = chr_header_end; 662 700 return ret_ok; 663 701 } … … 679 717 HEADER_INTERNAL_CHECK(hdr); 680 718 681 for (i=0; i < hdr->unknowns_len; i++) 682 { 719 for (i=0; i < hdr->unknowns_len; i++) { 683 720 char *h = hdr->unknowns[i].header_off + hdr->input_buffer->buf; 684 721 … … 850 887 cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, int tail_len) 851 888 { 852 int tail; 853 char *start; 854 855 /* Too few information? 856 * len("GET / HTTP/1.0" CRLF CRLF) = 18 857 */ 858 if (buffer->len < 18) { 859 return ret_deny; 889 char *start; 890 char *end; 891 size_t crlf_len = 0; 892 893 /* Skip initial CRLFs: 894 * NOTE: they are not allowed by standard (RFC) but many 895 * popular HTTP clients (including MSIE, etc.) may send a 896 * couple of them between two requests, so every widely used 897 * web server has to deal with them. 898 */ 899 crlf_len = cherokee_buffer_cnt_spn (buffer, 0, CRLF); 900 if (unlikely (crlf_len > MAX_HEADER_CRLF)) { 901 /* Too many initial CRLF 902 */ 903 return ret_error; 904 } 905 906 if (unlikely (tail_len < 0)) { 907 /* Bad parameter value 908 */ 909 return ret_error; 910 } 911 912 if ((crlf_len > 0) && (crlf_len < (size_t) buffer->len)) { 913 /* Found heading CRLFs and their length is less than 914 * buffer length so we have to move the real content 915 * to the beginning of the buffer. 916 */ 917 cherokee_buffer_move_to_begin(buffer, (int) crlf_len); 918 } 919 920 /* Do we have enough information ? 921 * len("GET /" CRLF_CRLF) = 9 (HTTP/0.9) 922 * len("GET / HTTP/1.0" CRLF_CRLF) = 18 (HTTP/1.x) 923 */ 924 if (unlikely (buffer->len < 18)) { 925 return ret_not_found; 860 926 } 861 927 862 928 /* Look for the starting point 863 929 */ 864 tail = (tail_len < buffer->len) ? tail_len : buffer->len;865 start = buffer->buf + (buffer->len - tail);930 start = (tail_len >= buffer->len) ? 931 buffer->buf : buffer->buf + (buffer->len - tail_len); 866 932 867 933 /* It could be a partial header, or maybe a POST request 868 934 */ 869 return (strstr(start, CRLF CRLF) != NULL) ? ret_ok : ret_error; 870 } 871 935 if (unlikely((end = strstr(start, CRLF_CRLF)) == NULL)) { 936 if ((end = strstr(start, LF_LF)) == NULL) 937 return ret_not_found; 938 939 /* Found uncommon / non standard EOH, set header length 940 */ 941 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(LF_LF); 942 return ret_ok; 943 } 944 945 /* Found standard EOH, set header length 946 */ 947 hdr->input_header_len = ((int) (end - buffer->buf)) + CSZLEN(CRLF_CRLF); 948 949 return ret_ok; 950 } 951 cherokee/trunk/cherokee/http.h
r215 r342 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_not_modified = 304, 94 http_bad_request = 400, 95 http_unauthorized = 401, 96 http_access_denied = 403, 97 http_not_found = 404, 98 http_method_not_allowed = 405, 99 http_length_required = 411, 100 http_request_uri_too_long = 414, 101 http_range_not_satisfiable = 416, 102 http_upgrade_required = 426, 103 http_internal_error = 500, 104 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 105 107 } cherokee_http_t; 106 108 107 /* 0 1 2 3 4 5 6 7 108 01234567890123456789012345678901234567890123456789012345678901234567890 */ 109 #define http_continue_string "100 Continue" 110 #define http_switching_protocols_string "101 Switching Protocols" 111 #define http_ok_string "200 OK" 112 #define http_accepted_string "202 Accepted" 113 #define http_partial_content_string "206 Partial Content" 114 #define http_moved_permanently_string "301 Moved Permanently" 115 #define http_moved_temporarily_string "302 Moved Temporarily" 116 #define http_not_modified_string "304 Not Modified" 117 #define http_bad_request_string "400 Bad Request" 118 #define http_unauthorized_string "401 Authorization Required" 119 #define http_access_denied_string "403 Forbidden" 120 #define http_not_found_string "404 Not Found" 121 #define http_method_not_allowed_string "405 Method Not Allowed" 122 #define http_length_required_string "411 Length Required" 123 #define http_request_uri_too_long_string "414 Request-URI too long" 124 #define http_range_not_satisfiable_string "416 Requested range not satisfiable" 125 #define http_upgrade_required_string "426 Upgrade Required" 126 #define http_internal_error_string "500 Internal Server Error" 127 #define http_service_unavailable_string "503 Service Unavailable" 109 #define http_continue_string "100 Continue" 110 #define http_switching_protocols_string "101 Switching Protocols" 111 #define http_ok_string "200 OK" 112 #define http_accepted_string "202 Accepted" 113 #define http_partial_content_string "206 Partial Content" 114 #define http_moved_permanently_string "301 Moved Permanently" 115 #define http_moved_temporarily_string "302 Moved Temporarily" 116 #define http_not_modified_string "304 Not Modified" 117 #define http_bad_request_string "400 Bad Request" 118 #define http_unauthorized_string "401 Authorization Required" 119 #define http_access_denied_string "403 Forbidden" 120 #define http_not_found_string "404 Not Found" 121 #define http_method_not_allowed_string "405 Method Not Allowed" 122 #define http_length_required_string "411 Length Required" 123 #define http_request_entity_too_large_string "413 Request Entity too large" 124 #define http_request_uri_too_long_string "414 Request-URI too long" 125 #define http_range_not_satisfiable_string "416 Requested range not satisfiable" 126 #define http_upgrade_required_string "426 Upgrade Required" 127 #define http_internal_error_string "500 Internal Server Error" 128 #define http_service_unavailable_string "503 Service Unavailable" 128 129 129 130 #define http_type_200_max 206 cherokee/trunk/cherokee/macros.h
r333 r342 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 */ 114 103 115 104 116 #define equal_str(m,str) \ cherokee/trunk/cherokee/thread.c
r324 r342 687 687 goto phase_reading_header_EXIT; 688 688 } 689 } 690 689 if (ret != ret_not_found) { 690 /* Too many initial CRLF */ 691 purge_closed_connection (thd, conn); 692 continue; 693 } 694 } 695 691 696 /* Read from the client 692 697 */ … … 722 727 continue; 723 728 } 729 /* fall down */ 724 730 725 731 phase_reading_header_EXIT: 726 732 conn->phase = phase_processing_header; 733 /* fall down */ 727 734 728 735 case phase_processing_header: … … 756 763 757 764 conn->phase = phase_setup_connection; 765 /* fall down */ 758 766 759 767 case phase_setup_connection: { cherokee/trunk/cherokee/unix4win32.c
r122 r342 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/trunk/cherokee/validator.c
r330 r342 165 165 /* Skip some chars 166 166 */ 167 while ((*entry == ' ') ||168 (*entry == '\r') ||169 (*entry == '\n')) entry++;167 while ((*entry == CHR_SP) || 168 (*entry == CHR_CR) || 169 (*entry == CHR_LF)) entry++; 170 170 171 171 /* Check for the end … … 215 215 while ((len > 0) && 216 216 ((equal[len-1] == '"') || 217 (equal[len-1] == '\r') ||218 (equal[len-1] == '\n'))) len--;217 (equal[len-1] == CHR_CR) || 218 (equal[len-1] == CHR_LF))) len--; 219 219 220 220 /* Copy the entry value cherokee/trunk/cherokee/validator_htdigest.c