Changeset 342

Show
Ignore:
Timestamp:
08/20/06 13:50:26 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/trunk/cherokee/buffer.c

    r269 r342  
    4242 
    4343 
    44 #define TO_HEX(c) (c>9? c+'a'-10 : c+'0') 
     44#define TO_HEX(c) (c > 9 ? c+'a'-10 : c+'0') 
    4545 
    4646ret_t 
     
    275275        } 
    276276 
    277         return (buf->buf[buf->len -1] == c); 
     277        return (buf->buf[buf->len - 1] == c); 
    278278} 
    279279 
     
    282282cherokee_buffer_move_to_begin (cherokee_buffer_t *buf, int pos) 
    283283{ 
    284         int offset; 
    285  
    286284        if (pos <= 0)  
    287285                return ret_ok; 
     
    290288                return cherokee_buffer_clean(buf); 
    291289 
    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; 
    295294 
    296295#if 0 
     
    647646                cherokee_buffer_ensure_size (buf, buf->len + 29 + sizeof(PACKAGE_VERSION) + 6 + port_len + 10); 
    648647 
    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 "); 
    652650                cherokee_buffer_add (buf, port_str, port_len); 
    653                 cherokee_buffer_add (buf, "</address>", 10); 
     651                cherokee_buffer_add_str (buf, "</address>"); 
    654652                break; 
    655653 
     
    657655                cherokee_buffer_ensure_size (buf, buf->len + 34 + port_len + 10); 
    658656 
    659                 cherokee_buffer_add (buf, "<address>Cherokee web server Port ", 34); 
     657                cherokee_buffer_add_str (buf, "<address>Cherokee web server Port "); 
    660658                cherokee_buffer_add (buf, port_str, port_len); 
    661                 cherokee_buffer_add (buf, "</address>", 10); 
     659                cherokee_buffer_add_str (buf, "</address>"); 
    662660                break; 
    663661 
  • cherokee/trunk/cherokee/buffer.h

    r269 r342  
    3434#include <stdarg.h> 
    3535#include <stdlib.h> 
     36#include <string.h> 
    3637 
    3738 
     
    5354 
    5455#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)
    5657#define cherokee_buffer_cmp_str(b,s)       cherokee_buffer_cmp (b, s, sizeof(s)) 
    5758#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)) 
    5861 
    5962 
  • cherokee/trunk/cherokee/connection.c

    r336 r342  
    212212{           
    213213        uint32_t           header_len; 
     214        size_t             crlf_len; 
    214215        cherokee_server_t *srv = CONN_SRV(cnt); 
    215216 
     
    286287        } 
    287288 
    288         /* Drop out the loast incoming header 
     289        /* Drop out the last incoming header 
    289290         */ 
    290291        cherokee_header_get_length (&cnt->header, &header_len); 
     
    293294        cherokee_buffer_clean (&cnt->buffer); 
    294295        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 
    295306        cherokee_buffer_move_to_begin (&cnt->incoming_header, header_len); 
    296307 
     
    446457        switch (cnt->header.version) { 
    447458        case http_version_09: 
     459                /* TODO: remove HTTP headers in this version */ 
    448460                cherokee_buffer_add_str (buffer, "HTTP/0.9 ");  
    449461                break; 
     
    703715         */ 
    704716        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
    706718                return ret_error; 
    707719        } 
     
    962974        /* ptr = Header at the "Accept-Encoding" position  
    963975         */ 
    964         end = strchr (ptr, '\r'); 
     976        end = strchr (ptr, CHR_CR); 
    965977        if (end == NULL) { 
    966978                return ret_error; 
     
    10051017        } while (i2 < end); 
    10061018 
    1007         *end = '\r'; /* (1') */ 
     1019        *end = CHR_CR; /* (1') */ 
    10081020        return ret_ok; 
    10091021 
    10101022error: 
    1011         *end = '\r'; /* (1') */ 
     1023        *end = CHR_CR; /* (1') */ 
    10121024        return ret_error; 
    10131025} 
     
    10521064        /* Skip end of line 
    10531065         */ 
    1054         end  = strchr (ptr, '\r'); 
    1055         end2 = strchr (ptr, '\n'); 
     1066        end  = strchr (ptr, CHR_CR); 
     1067        end2 = strchr (ptr, CHR_LF); 
    10561068 
    10571069        end = cherokee_min_str (end, end2); 
     
    12161228        /* Maybe there're an ending position 
    12171229         */ 
    1218         if ((*ptr != '\0') && (*ptr != '\r') && (*ptr != '\n')) { 
     1230        if ((*ptr != '\0') && (*ptr != CHR_CR) && (*ptr != CHR_LF)) { 
    12191231                num_len = 0; 
    12201232                 
  • cherokee/trunk/cherokee/downloader.c

    r336 r342  
    281281                 */ 
    282282                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 ...  
    285288                         */ 
    286289                        return ret_eagain; 
     290                default: 
     291                        /* Too many initial CRLF  
     292                         */ 
     293                        return ret_error; 
    287294                } 
    288295                 
  • cherokee/trunk/cherokee/handler_admin.c

    r333 r342  
    138138 
    139139        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); 
    142142                char *end  = cherokee_min_str (end1, end2); 
    143143 
     
    148148                 */ 
    149149                cherokee_buffer_add (&line, tmp, end - tmp); 
    150                 while ((*end == '\r') || (*end == '\n')) end++; 
     150                while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 
    151151                tmp = end; 
    152152 
  • cherokee/trunk/cherokee/handler_cgi.c

    r333 r342  
    541541                switch (errno) { 
    542542                case ENOENT: 
    543                         printf ("Status: 404" CRLF CRLF); 
     543                        printf ("Status: 404" CRLF_CRLF); 
    544544                        break; 
    545545                default: 
    546                         printf ("Status: 500" CRLF CRLF); 
     546                        printf ("Status: 500" CRLF_CRLF); 
    547547                } 
    548548 
  • cherokee/trunk/cherokee/handler_cgi_base.c

    r336 r342  
    621621                return ret_ok; 
    622622 
    623         /* It is possible that the header ends with CRLF CRLF 
     623        /* It is possible that the header ends with CRLF_CRLF 
    624624         * In this case, we have to remove the last two characters 
    625625         */ 
    626626        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)) 
    628628        { 
    629629                cherokee_buffer_drop_endding (buffer, 2); 
     
    634634        begin = buffer->buf; 
    635635        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); 
    638638 
    639639                end = cherokee_min_str (end1, end2); 
     
    641641 
    642642                end2 = end; 
    643                 while (((*end2 == '\r') || (*end2 == '\n')) && (*end2 != '\0')) end2++; 
     643                while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0')) end2++; 
    644644 
    645645                if (strncasecmp ("Status: ", begin, 8) == 0) { 
     
    714714        /* Look the end of headers 
    715715         */ 
    716         content = strstr (inbuf->buf, CRLF CRLF); 
     716        content = strstr (inbuf->buf, CRLF_CRLF); 
    717717        if (content != NULL) { 
    718718                end_len = 4; 
    719719        } else { 
    720                 content = strstr (inbuf->buf, "\n\n"); 
     720                content = strstr (inbuf->buf, LF_LF); 
    721721                end_len = 2; 
    722722        } 
     
    732732        cherokee_buffer_ensure_size (outbuf, len+6); 
    733733        cherokee_buffer_add (outbuf, inbuf->buf, len); 
    734         cherokee_buffer_add_str (outbuf, CRLF CRLF); 
     734        cherokee_buffer_add_str (outbuf, CRLF_CRLF); 
    735735 
    736736        /* Drop out the headers, we already have a copy 
  • cherokee/trunk/cherokee/handler_error.c

    r282 r342  
    118118                cherokee_buffer_add_str (buffer, "You have no access to the request URL"); 
    119119                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; 
    120124        case http_request_uri_too_long: 
    121125                cherokee_buffer_add_str (buffer, 
    122                                          "The requested URL's length exceeds the capacity limit for this server."); 
     126                                         "The length of requested URL exceeds the capacity limit for this server."); 
    123127                break;           
    124128        case http_moved_permanently: 
  • cherokee/trunk/cherokee/header-protected.h

    r240 r342  
    7676        cherokee_buffer_t      *input_buffer; 
    7777        crc_t                   input_buffer_crc; 
     78        uint32_t                input_header_start; 
    7879        uint32_t                input_header_len; 
    7980 
  • cherokee/trunk/cherokee/header.c

    r333 r342  
    5959        int i; 
    6060         
    61         for (i=0; i<HEADER_LENGTH; i++) 
    62         { 
     61        for (i=0; i<HEADER_LENGTH; i++) { 
    6362                hdr->header[i].info_off =  0; 
    6463                hdr->header[i].info_len = -1;                     
     
    115114        /* Sanity 
    116115         */ 
    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; 
    120119 
    121120        return ret_ok; 
     
    208207{ 
    209208        char *line  = buf->buf; 
    210         char *begin = line
     209        char *begin = buf->buf
    211210        char  tmp[4]; 
    212211        char *end; 
    213212 
    214         end = strchr (line, '\r'); 
     213        end = strchr (line, CHR_CR); 
    215214        if (end == NULL) { 
    216215                return ret_error; 
     
    223222        } 
    224223 
    225         /* Return the line endding 
     224        /* Return next line 
    226225         */ 
    227226        *next_pos = end + 2; 
     
    363362        char  *ptr; 
    364363        char  *restore; 
     364        char  chr_end; 
    365365 
    366366        /* Basic security check. The shortest possible request 
    367367         * "GET / HTTP/1.0" is 14 characters long.. 
    368368         */ 
    369         if (buf->len < 14) { 
     369        if (unlikely(buf->len < 14)) { 
    370370                return ret_error; 
    371371        } 
     
    373373        /* Look for the end of the request line 
    374374         */ 
    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; 
    380391        *end = '\0'; 
    381392        restore = end; 
    382  
    383         /* Return the line endding 
    384          */ 
    385         *next_pos = end + 2; 
    386393 
    387394        /* Get the method 
     
    454461        } 
    455462 
    456         *restore = '\r'
     463        *restore = chr_end
    457464        return ret_ok; 
    458465 
    459466error: 
    460         *restore = '\r'
     467        *restore = chr_end
    461468        return ret_error; 
    462469} 
     
    467474{ 
    468475        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         */ 
    472485        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 
     503ret_t  
     504cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_type_header_t type) 
    487505{ 
    488506        ret_t  ret; 
     
    491509        char  *colon; 
    492510        char  *header_end; 
     511        char  chr_header_end; 
    493512 
    494513        /* Check the buffer content 
    495514         */ 
    496515        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"); 
    498517                return ret_error; 
    499518        } 
     
    507526#endif 
    508527 
    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 
    521552         */ 
    522553        switch (type) { 
    523554        case header_type_request: 
    524555                /* Parse request. Something like this: 
    525                  * GET /icons/compressed.png HTTP/1.1\r\n 
     556                 * GET /icons/compressed.png HTTP/1.1CRLF 
    526557                 */ 
    527558                ret = parse_request_first_line (hdr, buffer, &begin); 
    528559                if (unlikely(ret < ret_ok)) { 
    529560                        PRINT_DEBUG ("ERROR: Failed to parse header_type_request:\n===\n%s===\n", buffer->buf); 
     561                        *header_end = chr_header_end; 
    530562                        return ret; 
    531563                } 
     
    536568                if (unlikely(ret < ret_ok)) { 
    537569                        PRINT_DEBUG ("ERROR: Failed to parse header_type_response:\n===\n%s===\n", buffer->buf); 
     570                        *header_end = chr_header_end; 
    538571                        return ret; 
    539572                } 
     
    546579 
    547580        default: 
     581                *header_end = chr_header_end; 
    548582                SHOULDNT_HAPPEN; 
    549583        } 
     
    552586        /* Parse the rest of headers 
    553587         */ 
    554         while ((end = get_new_line(begin)) && (end < header_end)
    555         {              
     588        while ((begin < header_end) && (end = get_new_line(begin)) != NULL
     589        { 
    556590                cuint_t header_len; 
    557591                char    first_char; 
    558                 char    end_char = *end; 
     592                char    chr_end    = *end; 
    559593 
    560594                *end = '\0'; 
    561595 
     596                /* Current line may have embedded CR+SP or CRLF+SP  
     597                 */ 
    562598                colon = strchr (begin, ':'); 
    563599                if (colon == NULL) { 
     
    565601                } 
    566602                 
    567                 if (end < colon +2) { 
     603                if (end < colon + 2) { 
    568604                        goto next; 
    569605                } 
     
    650686                if (ret < ret_ok) { 
    651687                        PRINT_ERROR_S ("ERROR: Failed to add_(un)known_header()\n"); 
     688                        *header_end = chr_header_end; 
    652689                        return ret; 
    653690                } 
    654691 
    655692        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++; 
    659696                begin = end; 
    660697        } 
    661          
     698 
     699        *header_end = chr_header_end; 
    662700        return ret_ok; 
    663701} 
     
    679717        HEADER_INTERNAL_CHECK(hdr); 
    680718 
    681         for (i=0; i < hdr->unknowns_len; i++) 
    682         { 
     719        for (i=0; i < hdr->unknowns_len; i++) { 
    683720                char *h = hdr->unknowns[i].header_off + hdr->input_buffer->buf; 
    684721 
     
    850887cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, int tail_len) 
    851888{ 
    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; 
    860926        } 
    861927 
    862928        /* Look for the starting point 
    863929         */ 
    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); 
    866932 
    867933        /* It could be a partial header, or maybe a POST request 
    868934         */ 
    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  
    8383 
    8484typedef 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 
    105107} cherokee_http_t; 
    106108 
    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" 
    128129 
    129130#define http_type_200_max 206 
  • cherokee/trunk/cherokee/macros.h

    r333 r342  
    8282#define DEFAULT_READ_SIZE             8192 
    8383#define MAX_HEADER_LEN                4096 
     84#define MAX_HEADER_CRLF               8  
    8485#define MAX_KEEPALIVE                 500 
    8586#define MAX_NEW_CONNECTIONS_PER_STEP  50 
     
    100101#define EXIT_SERVER_INIT                32 
    101102 
    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 
    103115 
    104116#define equal_str(m,str) \ 
  • cherokee/trunk/cherokee/thread.c

    r324 r342  
    687687                                        goto phase_reading_header_EXIT; 
    688688                                } 
    689                         } 
    690                                                  
     689                                if (ret != ret_not_found) { 
     690                                        /* Too many initial CRLF */ 
     691                                        purge_closed_connection (thd, conn); 
     692                                        continue; 
     693                                } 
     694                        } 
     695 
    691696                        /* Read from the client 
    692697                         */ 
     
    722727                                continue; 
    723728                        } 
     729                        /* fall down */ 
    724730 
    725731                phase_reading_header_EXIT: 
    726732                        conn->phase = phase_processing_header; 
     733                        /* fall down */ 
    727734 
    728735                case phase_processing_header: 
     
    756763                         
    757764                        conn->phase = phase_setup_connection; 
     765                        /* fall down */ 
    758766                         
    759767                case phase_setup_connection: { 
  • cherokee/trunk/cherokee/unix4win32.c

    r122 r342  
    104104        if (ptr == NULL) return NULL; 
    105105 
    106         len = strcspn (ptr, " \n\t\n\r"); 
     106        len = strcspn (ptr, " \t\n\r"); 
    107107 
    108108        if (!(entry = (char *) malloc (len + 1))) { 
  • cherokee/trunk/cherokee/validator.c

    r330 r342  
    165165                /* Skip some chars 
    166166                 */ 
    167                 while ((*entry == ' ')  || 
    168                        (*entry == '\r') ||  
    169                        (*entry == '\n')) entry++; 
     167                while ((*entry == CHR_SP)  || 
     168                       (*entry == CHR_CR) ||  
     169                       (*entry == CHR_LF)) entry++; 
    170170 
    171171                /* Check for the end 
     
    215215                while ((len > 0) && 
    216216                       ((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--; 
    219219 
    220220                /* Copy the entry value 
  • cherokee/trunk/cherokee/validator_htdigest.c