You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@hyperreal.org on 1999/12/09 13:05:11 UTC

cvs commit: apache-1.3/src/modules/proxy mod_proxy.h proxy_ftp.c

martin      99/12/09 04:05:11

  Modified:    src      CHANGES
               src/include httpd.h
               src/main buff.c http_protocol.c rfc1413.c util_script.c
               src/modules/proxy mod_proxy.h proxy_ftp.c
  Log:
  Replace all occurrences of "\012\015" by a macro CRLF. This makes
  the code (somewhat) more readable, and improves the portability
  to character sets other than ASCII (e.g., EBCDIC).
  This patch results in no functional change whatsoever on ASCII machines,
  but allows EBCDIC platforms to live without the ebcdic2ascii_strictly()
  kludge.
  
  Submitted by:   Paul Gilmartin <pg...@sweng.stortek.com>
  Reviewed by:    Jim Jgielski, Martin Kraemer
  
  Revision  Changes    Path
  1.1476    +9 -0      apache-1.3/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v
  retrieving revision 1.1475
  retrieving revision 1.1476
  diff -u -r1.1475 -r1.1476
  --- CHANGES	1999/12/09 05:20:52	1.1475
  +++ CHANGES	1999/12/09 12:04:59	1.1476
  @@ -1,5 +1,14 @@
   Changes with Apache 1.3.10
   
  +  *) Replace all occurrences of "\012\015" by a macro CRLF. This makes
  +     the code (somewhat) more readable, and improves the portability
  +     to character sets other than ASCII (e.g., EBCDIC).
  +     This patch results in no functional change whatsoever on ASCII
  +     machines, but allows EBCDIC platforms to live without the
  +     ebcdic2ascii_strictly() kludge.
  +     [Paul Gilmartin <pg...@sweng.stortek.com>, slightly modified
  +     by Martin Kraemer]
  +
     *) more fixes to mod_auth_digest:
        - better comparing of request-uri with uri parameter in Authorization
          header
  
  
  
  1.297     +4 -0      apache-1.3/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/include/httpd.h,v
  retrieving revision 1.296
  retrieving revision 1.297
  diff -u -r1.296 -r1.297
  --- httpd.h	1999/10/21 20:44:18	1.296
  +++ httpd.h	1999/12/09 12:05:02	1.297
  @@ -599,6 +599,8 @@
   #ifndef CHARSET_EBCDIC
   #define LF 10
   #define CR 13
  +#define CRLF "\015\012"
  +#define OS_ASC(c) (c)
   #else /* CHARSET_EBCDIC */
   #include "ebcdic.h"
   /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
  @@ -610,6 +612,8 @@
    */
   #define CR '\r'
   #define LF '\n'
  +#define CRLF "\r\n"
  +#define OS_ASC(c) (os_toascii[c])
   #endif /* CHARSET_EBCDIC */
   
   /* Possible values for request_rec.read_body (set by handling module):
  
  
  
  1.93      +14 -27    apache-1.3/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/buff.c,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- buff.c	1999/12/08 23:02:34	1.92
  +++ buff.c	1999/12/09 12:05:03	1.93
  @@ -540,16 +540,16 @@
   	*strp++ = ' ';
   	++i;
       }
  -    *strp++ = '\015';
  -    *strp = '\012';
  +    *strp++ = CR;
  +    *strp = LF;
   #ifdef CHARSET_EBCDIC
       /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
       ebcdic2ascii(&fb->outbase[fb->outchunk], &fb->outbase[fb->outchunk], CHUNK_HEADER_SIZE);
   #endif /*CHARSET_EBCDIC*/
   
       /* tack on the trailing CRLF, we've reserved room for this */
  -    fb->outbase[fb->outcnt++] = '\015';
  -    fb->outbase[fb->outcnt++] = '\012';
  +    fb->outbase[fb->outcnt++] = CR;
  +    fb->outbase[fb->outcnt++] = LF;
   
       fb->outchunk = -1;
   }
  @@ -874,27 +874,15 @@
   	}
   
   	ch = fb->inptr[i++];
  -#ifndef CHARSET_EBCDIC
  -	if (ch == '\012') {	/* got LF */
  -	    if (ct == 0)
  -		buff[ct++] = '\n';
  -/* if just preceeded by CR, replace CR with LF */
  -	    else if (buff[ct - 1] == '\015')
  -		buff[ct - 1] = '\n';
  -	    else if (ct < n - 1)
  -		buff[ct++] = '\n';
  -	    else
  -		i--;		/* no room for LF */
  -	    break;
  -	}
  -#else /* an EBCDIC machine: do the same, but convert to EBCDIC on the fly: */
  +#ifdef CHARSET_EBCDIC
   	if (fb->flags & B_ASCII2EBCDIC)
   	    ch = os_toebcdic[(unsigned char)ch];
  -	if (ch == os_toebcdic['\012']) {  /* got LF */
  +#endif
  +	if (ch == LF) {  /* got LF */
   	    if (ct == 0)
   		buff[ct++] = '\n';
   /* if just preceeded by CR, replace CR with LF */
  -	    else if (buff[ct - 1] == os_toebcdic['\015'])
  +	    else if (buff[ct - 1] == CR)
   		buff[ct - 1] = '\n';
   	    else if (ct < n - 1)
   		buff[ct++] = '\n';
  @@ -902,7 +890,6 @@
   		i--;		/* no room for LF */
   	    break;
   	}
  -#endif
   	if (ct == n - 1) {
   	    i--;		/* push back ch */
   	    break;
  @@ -1159,7 +1146,7 @@
   #ifdef NO_WRITEV
       /* without writev() this has poor performance, too bad */
   
  -    ap_snprintf(chunksize, sizeof(chunksize), "%x\015\012", nbyte);
  +    ap_snprintf(chunksize, sizeof(chunksize), "%x" CRLF, nbyte);
   #ifdef CHARSET_EBCDIC
       /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
       ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
  @@ -1168,12 +1155,12 @@
   	return -1;
       if (write_it_all(fb, buf, nbyte) == -1)
   	return -1;
  -    if (write_it_all(fb, "\015\012", 2) == -1)
  +    if (write_it_all(fb, CRLF, 2) == -1)
   	return -1;
       return nbyte;
   #else
       vec[0].iov_base = chunksize;
  -    vec[0].iov_len = ap_snprintf(chunksize, sizeof(chunksize), "%x\015\012",
  +    vec[0].iov_len = ap_snprintf(chunksize, sizeof(chunksize), "%x" CRLF,
   				 nbyte);
   #ifdef CHARSET_EBCDIC
       /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
  @@ -1181,7 +1168,7 @@
   #endif /*CHARSET_EBCDIC*/
       vec[1].iov_base = (void *) buf;	/* cast is to avoid const warning */
       vec[1].iov_len = nbyte;
  -    vec[2].iov_base = "\015\012";
  +    vec[2].iov_base = CRLF;
       vec[2].iov_len = 2;
   
       return writev_it_all(fb, vec, (sizeof(vec) / sizeof(vec[0]))) ? -1 : nbyte;
  @@ -1213,7 +1200,7 @@
       if (fb->flags & B_CHUNK) {
   	vec[nvec].iov_base = chunksize;
   	vec[nvec].iov_len = ap_snprintf(chunksize, sizeof(chunksize),
  -					"%x\015\012", nbyte);
  +					"%x" CRLF, nbyte);
   #ifdef CHARSET_EBCDIC
       /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
   	ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
  @@ -1222,7 +1209,7 @@
   	vec[nvec].iov_base = (void *) buf;
   	vec[nvec].iov_len = nbyte;
   	++nvec;
  -	vec[nvec].iov_base = "\015\012";
  +	vec[nvec].iov_base = CRLF;
   	vec[nvec].iov_len = 2;
   	++nvec;
       }
  
  
  
  1.283     +14 -14    apache-1.3/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/http_protocol.c,v
  retrieving revision 1.282
  retrieving revision 1.283
  diff -u -r1.282 -r1.283
  --- http_protocol.c	1999/12/06 12:41:39	1.282
  +++ http_protocol.c	1999/12/09 12:05:03	1.283
  @@ -244,7 +244,7 @@
       if (!**r_range) {
           if (r->byterange > 1) {
               if (realreq)
  -                ap_rvputs(r, "\015\012--", r->boundary, "--\015\012", NULL);
  +                ap_rvputs(r, CRLF "--", r->boundary, "--" CRLF, NULL);
               else
                   *tlength += 4 + strlen(r->boundary) + 4;
           }
  @@ -271,8 +271,8 @@
           ap_snprintf(ts, sizeof(ts), "%ld-%ld/%ld", range_start, range_end,
                       r->clength);
           if (realreq)
  -            ap_rvputs(r, "\015\012--", r->boundary, "\015\012Content-type: ",
  -                   ct, "\015\012Content-range: bytes ", ts, "\015\012\015\012",
  +            ap_rvputs(r, CRLF "--", r->boundary, CRLF "Content-type: ",
  +                   ct, CRLF "Content-range: bytes ", ts, CRLF CRLF,
                      NULL);
           else
               *tlength += 4 + strlen(r->boundary) + 16 + strlen(ct) + 23 +
  @@ -1334,7 +1334,7 @@
   API_EXPORT_NONSTD(int) ap_send_header_field(request_rec *r,
       const char *fieldname, const char *fieldval)
   {
  -    return (0 < ap_rvputs(r, fieldname, ": ", fieldval, "\015\012", NULL));
  +    return (0 < ap_rvputs(r, fieldname, ": ", fieldval, CRLF, NULL));
   }
   
   API_EXPORT(void) ap_basic_http_header(request_rec *r)
  @@ -1366,7 +1366,7 @@
   
       /* Output the HTTP/1.x Status-Line and the Date and Server fields */
   
  -    ap_rvputs(r, protocol, " ", r->status_line, "\015\012", NULL);
  +    ap_rvputs(r, protocol, " ", r->status_line, CRLF, NULL);
   
       ap_send_header_field(r, "Date", ap_gm_timestr_822(r->pool, r->request_time));
       ap_send_header_field(r, "Server", ap_get_server_version());
  @@ -1401,9 +1401,9 @@
   
       ap_bgetopt(client, BO_BYTECT, &bs);
       if (bs >= 255 && bs <= 257)
  -        ap_bputs("X-Pad: avoid browser bug\015\012", client);
  +        ap_bputs("X-Pad: avoid browser bug" CRLF, client);
   
  -    ap_bputs("\015\012", client);  /* Send the terminating empty line */
  +    ap_bputs(CRLF, client);  /* Send the terminating empty line */
   }
   
   /* Build the Allow field-value from the request handler method mask.
  @@ -1448,11 +1448,11 @@
   
       /* Now we recreate the request, and echo it back */
   
  -    ap_rvputs(r, r->the_request, "\015\012", NULL);
  +    ap_rvputs(r, r->the_request, CRLF, NULL);
   
       ap_table_do((int (*) (void *, const char *, const char *))
                   ap_send_header_field, (void *) r, r->headers_in, NULL);
  -    ap_rputs("\015\012", r);
  +    ap_rputs(CRLF, r);
   
       ap_kill_timeout(r);
       return OK;
  @@ -1691,9 +1691,9 @@
           ap_bsetflag(r->connection->client, B_CHUNK, 0);
   
           ap_soft_timeout("send ending chunk", r);
  -        ap_rputs("0\015\012", r);
  +        ap_rputs("0" CRLF, r);
           /* If we had footer "headers", we'd send them now */
  -        ap_rputs("\015\012", r);
  +        ap_rputs(CRLF, r);
           ap_kill_timeout(r);
       }
   }
  @@ -1819,7 +1819,7 @@
   
       if (r->expecting_100 && r->proto_num >= HTTP_VERSION(1,1)) {
           /* sending 100 Continue interim response */
  -        ap_rvputs(r, SERVER_PROTOCOL, " ", status_lines[0], "\015\012\015\012",
  +        ap_rvputs(r, SERVER_PROTOCOL, " ", status_lines[0], CRLF CRLF,
                     NULL);
           ap_rflush(r);
       }
  @@ -2694,8 +2694,8 @@
   	    }
   	    break;
   	case BAD_GATEWAY:
  -	    ap_rputs("The proxy server received an invalid\015\012"
  -	             "response from an upstream server.<P>\015\012", r);
  +	    ap_rputs("The proxy server received an invalid" CRLF
  +	             "response from an upstream server.<P>" CRLF, r);
   	    if ((error_notes = ap_table_get(r->notes, "error-notes")) != NULL) {
   		ap_rvputs(r, error_notes, "<P>\n", NULL);
   	    }
  
  
  
  1.31      +1 -1      apache-1.3/src/main/rfc1413.c
  
  Index: rfc1413.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/rfc1413.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- rfc1413.c	1999/09/01 04:21:17	1.30
  +++ rfc1413.c	1999/12/09 12:05:04	1.31
  @@ -179,7 +179,7 @@
       i = 0;
       memset(buffer, '\0', sizeof(buffer));
       /*
  -     * Note that the strchr function below checks for 10 instead of '\n'
  +     * Note that the strchr function below checks for \012 instead of '\n'
        * this allows it to work on both ASCII and EBCDIC machines.
        */
       while((cp = strchr(buffer, '\012')) == NULL && i < sizeof(buffer) - 1) {
  
  
  
  1.148     +5 -1      apache-1.3/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/main/util_script.c,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- util_script.c	1999/11/27 14:48:36	1.147
  +++ util_script.c	1999/12/09 12:05:04	1.148
  @@ -486,8 +486,12 @@
   	/* Delete terminal (CR?)LF */
   
   	p = strlen(w);
  +        /* Indeed, the host's '\n':
  +           '\012' for UNIX; '\015' for MacOS; '\025' for OS/390
  +           -- whatever the script generates.
  +        */
   	if (p > 0 && w[p - 1] == '\n') {
  -	    if (p > 1 && w[p - 2] == '\015') {
  +	    if (p > 1 && w[p - 2] == CR) {
   		w[p - 2] = '\0';
   	    }
   	    else {
  
  
  
  1.45      +0 -7      apache-1.3/src/modules/proxy/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/mod_proxy.h,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- mod_proxy.h	1999/10/11 21:33:34	1.44
  +++ mod_proxy.h	1999/12/09 12:05:06	1.45
  @@ -128,13 +128,6 @@
   /* maximum  'CacheDirLevels*CacheDirLength' value */
   #define CACHEFILE_LEN 20	/* must be less than HASH_LEN/2 */
   
  -#ifdef CHARSET_EBCDIC
  -#define CRLF   "\r\n"
  -#else /*CHARSET_EBCDIC*/
  -#define CRLF   "\015\012"
  -#endif /*CHARSET_EBCDIC*/
  -
  -
   #define	SEC_ONE_DAY		86400	/* one day, in seconds */
   #define	SEC_ONE_HR		3600	/* one hour, in seconds */
   
  
  
  
  1.80      +2 -6      apache-1.3/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.79
  retrieving revision 1.80
  diff -u -r1.79 -r1.80
  --- proxy_ftp.c	1999/12/08 23:02:48	1.79
  +++ proxy_ftp.c	1999/12/09 12:05:06	1.80
  @@ -102,11 +102,7 @@
   	    ch = ap_proxy_hex2c(&x[i + 1]);
   	    i += 2;
   	}
  -#ifndef CHARSET_EBCDIC
  -	if (ch == '\015' || ch == '\012' || (ch & 0x80))
  -#else /*CHARSET_EBCDIC*/
  -	if (ch == '\r' || ch == '\n' || (os_toascii[ch] & 0x80))
  -#endif /*CHARSET_EBCDIC*/
  +	if (ch == CR || ch == LF || (OS_ASC(ch) & 0x80))
   	    return 0;
       }
       return 1;
  @@ -780,7 +776,7 @@
   
       if (parms[0] != 'a') {
   	/* set type to image */
  -	/* TM - Added \015\012 to the end of TYPE I, otherwise it hangs the
  +	/* TM - Added CRLF to the end of TYPE I, otherwise it hangs the
   	   connection */
   	ap_bputs("TYPE I" CRLF, f);
   	ap_bflush(f);