Changeset 341

Show
Ignore:
Timestamp:
08/19/06 17:24:22 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee/branches/0.5/ChangeLog

    r335 r341  
     12006-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         
     92006-08-18  Alvaro Lopez Ortega  <alvaro@alobbs.com> 
     10 
     11        * cherokee/buffer.c (cherokee_buffer_add_version): A little clean 
     12        up. 
     13 
    1142006-08-09  A.D.F  <adefacc@tin.it> 
    215 
  • cherokee/branches/0.5/cherokee/buffer.c

    r234 r341  
    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 
     
    259259        } 
    260260 
    261         return (buf->buf[buf->len -1] == c); 
     261        return (buf->buf[buf->len - 1] == c); 
    262262} 
    263263 
     
    266266cherokee_buffer_move_to_begin (cherokee_buffer_t *buf, int pos) 
    267267{ 
    268         int offset; 
    269  
    270268        if (pos <= 0)  
    271269                return ret_ok; 
     
    274272                return cherokee_buffer_clean(buf); 
    275273 
    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; 
    279278 
    280279#if 0 
     
    631630                cherokee_buffer_ensure_size (buf, buf->len + 29 + sizeof(PACKAGE_VERSION) + 6 + port_len + 10); 
    632631 
    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 "); 
    636634                cherokee_buffer_add (buf, port_str, port_len); 
    637                 cherokee_buffer_add (buf, "</address>", 10); 
     635                cherokee_buffer_add_str (buf, "</address>"); 
    638636                break; 
    639637 
     
    641639                cherokee_buffer_ensure_size (buf, buf->len + 34 + port_len + 10); 
    642640 
    643                 cherokee_buffer_add (buf, "<address>Cherokee web server Port ", 34); 
     641                cherokee_buffer_add_str (buf, "<address>Cherokee web server Port "); 
    644642                cherokee_buffer_add (buf, port_str, port_len); 
    645                 cherokee_buffer_add (buf, "</address>", 10); 
     643                cherokee_buffer_add_str (buf, "</address>"); 
    646644                break; 
    647645 
  • cherokee/branches/0.5/cherokee/buffer.h

    r122 r341  
    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)) 
    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)) 
    6061 
    6162 
  • cherokee/branches/0.5/cherokee/connection.c

    r334 r341  
    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 
     
    447458        switch (cnt->header.version) { 
    448459        case http_version_09: 
     460                /* TODO: remove HTTP headers in this version */ 
    449461                cherokee_buffer_add_str (buffer, "HTTP/0.9 ");  
    450462                break; 
     
    702714         */ 
    703715        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
    705717                return ret_error; 
    706718        } 
     
    961973        /* ptr = Header at the "Accept-Encoding" position  
    962974         */ 
    963         end = strchr (ptr, '\r'); 
     975        end = strchr (ptr, CHR_CR); 
    964976        if (end == NULL) { 
    965977                return ret_error; 
     
    10041016        } while (i2 < end); 
    10051017 
    1006         *end = '\r'; /* (1') */ 
     1018        *end = CHR_CR; /* (1') */ 
    10071019        return ret_ok; 
    10081020 
    10091021error: 
    1010         *end = '\r'; /* (1') */ 
     1022        *end = CHR_CR; /* (1') */ 
    10111023        return ret_error; 
    10121024} 
     
    10511063        /* Skip end of line 
    10521064         */ 
    1053         end  = strchr (ptr, '\r'); 
    1054         end2 = strchr (ptr, '\n'); 
     1065        end  = strchr (ptr, CHR_CR); 
     1066        end2 = strchr (ptr, CHR_LF); 
    10551067 
    10561068        end = cherokee_min_str (end, end2); 
     
    12151227        /* Maybe there're an ending position 
    12161228         */ 
    1217         if ((*ptr != '\0') && (*ptr != '\r') && (*ptr != '\n')) { 
     1229        if ((*ptr != '\0') && (*ptr != CHR_CR) && (*ptr != CHR_LF)) { 
    12181230                num_len = 0; 
    12191231                 
  • cherokee/branches/0.5/cherokee/downloader.c

    r195 r341  
    332332                 */ 
    333333                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 ...  
    336339                         */ 
    337340                        return ret_eagain; 
     341                default: 
     342                        /* Too many initial CRLF  
     343                         */ 
     344                        return ret_error; 
    338345                } 
    339346                 
  • cherokee/branches/0.5/cherokee/handler_admin.c

    r332 r341  
    133133 
    134134        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); 
    137137                char *end  = cherokee_min_str (end1, end2); 
    138138 
     
    143143                 */ 
    144144                cherokee_buffer_add (&line, tmp, end - tmp); 
    145                 while ((*end == '\r') || (*end == '\n')) end++; 
     145                while ((*end == CHR_CR) || (*end == CHR_LF)) end++; 
    146146                tmp = end; 
    147147 
  • cherokee/branches/0.5/cherokee/handler_cgi.c

    r332 r341  
    515515                switch (errno) { 
    516516                case ENOENT: 
    517                         printf ("Status: 404" CRLF CRLF); 
     517                        printf ("Status: 404" CRLF_CRLF); 
    518518                        break; 
    519519                default: 
    520                         printf ("Status: 500" CRLF CRLF); 
     520                        printf ("Status: 500" CRLF_CRLF); 
    521521                } 
    522522 
  • cherokee/branches/0.5/cherokee/handler_cgi_base.c

    r334 r341  
    534534                return ret_ok; 
    535535 
    536         /* It is possible that the header ends with CRLF CRLF 
     536        /* It is possible that the header ends with CRLF_CRLF 
    537537         * In this case, we have to remove the last two characters 
    538538         */ 
    539539        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)) 
    541541        { 
    542542                cherokee_buffer_drop_endding (buffer, 2); 
     
    547547        begin = buffer->buf; 
    548548        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); 
    551551 
    552552                end = cherokee_min_str (end1, end2); 
     
    554554 
    555555                end2 = end; 
    556                 while (((*end2 == '\r') || (*end2 == '\n')) && (*end2 != '\0')) end2++; 
     556                while (((*end2 == CHR_CR) || (*end2 == CHR_LF)) && (*end2 != '\0')) end2++; 
    557557 
    558558                if (strncasecmp ("Status: ", begin, 8) == 0) { 
     
    627627        /* Look the end of headers 
    628628         */ 
    629         content = strstr (inbuf->buf, CRLF CRLF); 
     629        content = strstr (inbuf->buf, CRLF_CRLF); 
    630630        if (content != NULL) { 
    631631                end_len = 4; 
    632632        } else { 
    633                 content = strstr (inbuf->buf, "\n\n"); 
     633                content = strstr (inbuf->buf, LF_LF); 
    634634                end_len = 2; 
    635635        } 
     
    645645        cherokee_buffer_ensure_size (outbuf, len+6); 
    646646        cherokee_buffer_add (outbuf, inbuf->buf, len); 
    647         cherokee_buffer_add_str (outbuf, CRLF CRLF); 
     647        cherokee_buffer_add_str (outbuf, CRLF_CRLF); 
    648648 
    649649        /* Drop out the headers, we already have a copy 
  • cherokee/branches/0.5/cherokee/handler_error.c

    r258 r341  
    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/branches/0.5/cherokee/header-protected.h

    r240 r341  
    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/branches/0.5/cherokee/header.c

    r332 r341  
    115115        /* Sanity 
    116116         */ 
    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; 
    120120 
    121121        return ret_ok; 
     
    208208{ 
    209209        char *line  = buf->buf; 
    210         char *begin = line
     210        char *begin = buf->buf
    211211        char  tmp[4]; 
    212212        char *end; 
    213213 
    214         end = strchr (line, '\r'); 
     214        end = strchr (line, CHR_CR); 
    215215        if (end == NULL) { 
    216216                return ret_error; 
     
    223223        } 
    224224 
    225         /* Return the line endding 
     225        /* Return next line 
    226226         */ 
    227227        *next_pos = end + 2; 
     
    363363        char  *ptr; 
    364364        char  *restore; 
     365        char  chr_end; 
    365366 
    366367        /* Basic security check. The shortest possible request 
    367368         * "GET / HTTP/1.0" is 14 characters long.. 
    368369         */ 
    369         if (buf->len < 14) { 
     370        if (unlikely(buf->len < 14)) { 
    370371                return ret_error; 
    371372        } 
     
    373374        /* Look for the end of the request line 
    374375         */ 
    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; 
    380392        *end = '\0'; 
    381393        restore = end; 
    382  
    383         /* Return the line endding 
    384          */ 
    385         *next_pos = end + 2; 
    386394 
    387395        /* Get the method 
     
    454462        } 
    455463 
    456         *restore = '\r'
     464        *restore = chr_end
    457465        return ret_ok; 
    458466 
    459467error: 
    460         *restore = '\r'
     468        *restore = chr_end
    461469        return ret_error; 
    462470} 
     
    467475{ 
    468476        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         */ 
    472486        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 
     504ret_t  
     505cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_type_header_t type) 
    487506{ 
    488507        ret_t  ret; 
     
    491510        char  *colon; 
    492511        char  *header_end; 
     512        char  chr_header_end; 
    493513 
    494514        /* Check the buffer content 
    495515         */ 
    496516        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"); 
    498518                return ret_error; 
    499519        } 
     
    507527#endif 
    508528 
    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 
    521553         */ 
    522554        switch (type) { 
    523555        case header_type_request: 
    524556                /* Parse request. Something like this: 
    525                  * GET /icons/compressed.png HTTP/1.1\r\n 
     557                 * GET /icons/compressed.png HTTP/1.1CRLF 
    526558                 */ 
    527559                ret = parse_request_first_line (hdr, buffer, &begin); 
    528560                if (unlikely(ret < ret_ok)) { 
    529561                        PRINT_DEBUG ("ERROR: Failed to parse header_type_request:\n===\n%s===\n", buffer->buf); 
     562                        *header_end = chr_header_end; 
    530563                        return ret; 
    531564                } 
     
    536569                if (unlikely(ret < ret_ok)) { 
    537570                        PRINT_DEBUG ("ERROR: Failed to parse header_type_response:\n===\n%s===\n", buffer->buf); 
     571                        *header_end = chr_header_end; 
    538572                        return ret; 
    539573                } 
     
    546580 
    547581        default: 
     582                *header_end = chr_header_end; 
    548583                SHOULDNT_HAPPEN; 
    549584        } 
     
    552587        /* Parse the rest of headers 
    553588         */ 
    554         while ((end = get_new_line(begin)) && (end < header_end)
    555         {              
     589        while ((begin < header_end) && (end = get_new_line(begin)) != NULL
     590        { 
    556591                cuint_t header_len; 
    557592                char    first_char; 
    558                 char    end_char = *end; 
     593                char    chr_end    = *end; 
    559594 
    560595                *end = '\0'; 
    561596 
     597                /* Current line may have embedded CR+SP or CRLF+SP  
     598                 */ 
    562599                colon = strchr (begin, ':'); 
    563600                if (colon == NULL) { 
     
    565602                } 
    566603                 
    567                 if (end < colon +2) { 
     604                if (end < colon + 2) { 
    568605                        goto next; 
    569606                } 
     
    650687                if (ret < ret_ok) { 
    651688                        PRINT_ERROR_S ("ERROR: Failed to add_(un)known_header()\n"); 
     689                        *header_end = chr_header_end; 
    652690                        return ret; 
    653691                } 
    654692 
    655693        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++; 
    659697                begin = end; 
    660698        } 
    661          
     699 
     700        *header_end = chr_header_end; 
    662701        return ret_ok; 
    663702} 
     
    859898        /* Known headers 
    860899         */ 
    861         for (i=0; i<HEADER_LENGTH; i++) 
    862         { 
     900        for (i=0; i<HEADER_LENGTH; i++) { 
    863901                if (hdr->header[i].info_off != 0) { 
    864902                        num++; 
     
    876914cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, int tail_len) 
    877915{ 
    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; 
    886953        } 
    887954 
    888955        /* Look for the starting point 
    889956         */ 
    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); 
    892959 
    893960        /* It could be a partial header, or maybe a POST request 
    894961         */ 
    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  
    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_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 
    106107} cherokee_http_t; 
    107108 
     
    123124#define http_method_not_allowed_string    "405 Method Not Allowed" 
    124125#define http_length_required_string       "411 Length Required" 
     126#define http_request_entity_too_large_string "413 Request Entity too large" 
    125127#define http_request_uri_too_long_string  "414 Request-URI too long" 
    126128#define http_range_not_satisfiable_string "416 Requested range not satisfiable" 
  • cherokee/branches/0.5/cherokee/macros.h

    r332 r341  
    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 */ 
    103114 
    104115#define return_if_fail(expr,ret) \ 
  • cherokee/branches/0.5/cherokee/thread.c

    r321 r341  
    686686                                        goto phase_reading_header_EXIT; 
    687687                                } 
    688                         } 
    689                                                  
     688                                if (ret != ret_not_found) { 
     689                                        /* Too many initial CRLF */ 
     690                                        purge_closed_connection (thd, conn); 
     691                                        continue; 
     692                                } 
     693                        } 
     694 
    690695                        /* Read from the client 
    691696                         */ 
     
    721726                                continue; 
    722727                        } 
     728                        /* fall down */ 
    723729 
    724730                phase_reading_header_EXIT: 
    725731                        conn->phase = phase_processing_header; 
     732                        /* fall down */ 
    726733 
    727734                case phase_processing_header: 
     
    755762                         
    756763                        conn->phase = phase_setup_connection; 
     764                        /* fall down */ 
    757765                         
    758766                case phase_setup_connection: { 
  • cherokee/branches/0.5/cherokee/unix4win32.c

    r122 r341  
    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/branches/0.5/cherokee/validator.c

    r220 r341  
    163163                /* Skip some chars 
    164164                 */ 
    165                 while ((*entry == ' ')  || 
    166                        (*entry == '\r') ||  
    167                        (*entry == '\n')) entry++; 
     165                while ((*entry == CHR_SP)  || 
     166                       (*entry == CHR_CR) ||  
     167                       (*entry == CHR_LF)) entry++; 
    168168 
    169169                /* Check for the end 
     
    213213                while ((len > 0) && 
    214214                       ((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--; 
    217217 
    218218                /* Copy the entry value 
  • cherokee/branches/0.5/cherokee/validator_htdigest.c

    r332 r341  
    121121                 */ 
    122122                pos = eol; 
    123                 while ((*pos == '\r') || (*pos == '\n')) pos++; 
     123                while ((*pos == CHR_CR) || (*pos == CHR_LF)) pos++; 
    124124        } 
    125125