httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grega...@locus.apache.org
Subject cvs commit: apache-2.0/src/main http_protocol.c
Date Thu, 19 Oct 2000 17:57:44 GMT
gregames    00/10/19 10:57:43

  Modified:    src/main http_protocol.c
  Log:
  getline():
   Fix MIME header folding for character mode (telnet) clients.
   Clean up comments & tighten asserts.
  
  Revision  Changes    Path
  1.193     +20 -16    apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.192
  retrieving revision 1.193
  diff -u -r1.192 -r1.193
  --- http_protocol.c	2000/10/19 00:04:55	1.192
  +++ http_protocol.c	2000/10/19 17:57:42	1.193
  @@ -1022,14 +1022,13 @@
    * caused by MIME folding (or broken clients) if fold != 0, and place it
    * in the buffer s, of size n bytes, without the ending newline.
    *
  - * Returns -1 on error, or the length of s.
  + * Returns -1 on error, or the length of s.  
    *
  - * Note: Because bgets uses 1 char for newline and 1 char for NUL,
  - *       the most we can get is (n - 2) actual characters if it
  - *       was ended by a newline, or (n - 1) characters if the line
  - *       length exceeded (n - 1).  So, if the result == (n - 1),
  - *       then the actual input line exceeded the buffer length,
  - *       and it would be a good idea for the caller to puke 400 or 414.
  + * Notes: Because the buffer uses 1 char for NUL, the most we can return is 
  + *        (n - 1) actual characters.  
  + *
  + *        If no LF is detected on the last line due to a dropped connection 
  + *        or a full buffer, that's considered an error.
    */
   static int getline(char *s, int n, request_rec *r, int fold)
   {
  @@ -1073,9 +1072,11 @@
           }
   
           if ((looking_ahead) && (*temp != ' ') && (*temp != '\t')) { 
  -            /* just checking, but can't fold because next line isn't
  -             * indented
  +            /* can't fold because next line isn't indented, 
  +             * so return what we have.  lookahead brigade is 
  +             * stashed on req_cfg->bb
                */
  +            AP_DEBUG_ASSERT(!AP_BRIGADE_EMPTY(req_cfg->bb));
               break;
           }
           last_char = pos + length - 1;
  @@ -1115,23 +1116,26 @@
                   --pos;          /* trim extra trailing spaces or tabs    */
               }
               *pos = '\0';        /* zap end of string                     */
  +            total = pos - s;    /* update total string length            */
   
               /* look ahead another line if line folding is desired 
  -             * and the last line wasn't empty
  +             * and this line isn't empty
                */
  -            looking_ahead = (fold && ((pos - s) > total));
  -            total = pos - s;    /* update total string length            */
  -            if (!looking_ahead) {
  -                AP_DEBUG_ASSERT(AP_BRIGADE_EMPTY(b));
  -                break;          /* normal loop exit                      */
  +            if (fold && total) {
  +                looking_ahead = 1;
  +            }
  +            else {
  +                AP_DEBUG_ASSERT(AP_BRIGADE_EMPTY(req_cfg->bb));
  +                break;
               }
           }
           else {
  -            /* no LF yet...keep going
  +            /* no LF yet...character mode client (telnet)...keep going
                * bump past last character read,   
                * and set total in case we bail before finding a LF   
                */
               total = ++pos - s;    
  +            looking_ahead = 0;  /* only appropriate right after LF       */ 
           }
       }
       return total;
  
  
  

Mime
View raw message