httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgau...@hyperreal.org
Subject cvs commit: apache-2.0/mpm/src/main buff.c http_protocol.c
Date Fri, 18 Jun 1999 19:20:50 GMT
dgaudet     99/06/18 12:20:50

  Modified:    mpm/src/include buff.h
               mpm/src/main buff.c http_protocol.c
  Log:
  break chunked encoding, ebcdic, ... layering goes here
  
  Revision  Changes    Path
  1.2       +4 -48     apache-2.0/mpm/src/include/buff.h
  
  Index: buff.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/include/buff.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- buff.h	1999/06/18 18:39:28	1.1
  +++ buff.h	1999/06/18 19:20:47	1.2
  @@ -62,10 +62,6 @@
   extern "C" {
   #endif
   
  -#ifdef B_SFIO
  -#include "sfio.h"
  -#endif
  -
   #include <stdarg.h>
   
   /* Reading is buffered */
  @@ -85,16 +81,13 @@
   #undef B_ERROR
   #endif
   #define B_ERROR (48)
  -/* Use chunked writing */
  -#define B_CHUNK (64)
  +/* TODO: implement chunked encoding as a layer */
   /* bflush() if a read would block */
   #define B_SAFEREAD (128)
   /* buffer is a socket */
   #define B_SOCKET (256)
  -#ifdef CHARSET_EBCDIC
  -#define B_ASCII2EBCDIC 0x40000000  /* Enable conversion for this buffer */
  -#define B_EBCDIC2ASCII 0x80000000  /* Enable conversion for this buffer */
  -#endif /*CHARSET_EBCDIC*/
  +
  +/* TODO: implement a ebcdic/ascii conversion layers */
   
   typedef struct buff_struct BUFF;
   
  @@ -103,7 +96,6 @@
       unsigned char *inptr;	/* pointer to next location to read */
       int incnt;			/* number of bytes left to read from input buffer;
   				 * always 0 if had a read error  */
  -    int outchunk;		/* location of chunk header when chunking */
       int outcnt;			/* number of byte put in output buffer */
       unsigned char *inbase;
       unsigned char *outbase;
  @@ -116,29 +108,9 @@
   
   /* could also put pointers to the basic I/O routines here */
       int fd;			/* the file descriptor */
  -#ifdef WIN32
  -    HANDLE hFH;			/* Windows filehandle */
  -#endif
       time_t timeout;		/* timeout for B_SOCKET operations */
  -
  -    /* transport handle, for RPC binding handle or some such */
  -    void *t_handle;
  -
  -#ifdef B_SFIO
  -    Sfio_t *sf_in;
  -    Sfio_t *sf_out;
  -#endif
   };
   
  -#ifdef B_SFIO
  -typedef struct {
  -    Sfdisc_t disc;
  -    BUFF *buff;
  -} apache_sfio;
  -
  -extern Sfdisc_t *bsfio_new(pool *p, BUFF *b);
  -#endif
  -
   /* Options to bset/getopt */
   #define BO_BYTECT (1)
   #define BO_TIMEOUT (2)
  @@ -150,9 +122,6 @@
   /* XXX - unused right now - mvsk */
   API_EXPORT(BUFF *) ap_bopenf(pool *a, const char *name, int flg, int mode);
   
  -#ifdef WIN32
  -API_EXPORT(void) ap_bpushh(BUFF *fb, HANDLE hFH);
  -#endif
   API_EXPORT(int) ap_bsetopt(BUFF *fb, int optname, const void *optval);
   API_EXPORT(int) ap_bgetopt(BUFF *fb, int optname, void *optval);
   API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value);
  @@ -181,27 +150,14 @@
   API_EXPORT(int) ap_bflsbuf(int c, BUFF *fb);
   API_EXPORT(int) ap_bfilbuf(BUFF *fb);
   
  -#ifndef CHARSET_EBCDIC
  -
   #define ap_bgetc(fb)   ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \
   		    ((fb)->incnt--, *((fb)->inptr++)) )
   
   #define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \
   		     (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \
   		     ((fb)->outbase[(fb)->outcnt++] = (c), 0))
  -
  -#else /*CHARSET_EBCDIC*/
  -
  -#define ap_bgetc(fb)   ( ((fb)->incnt == 0) ? ap_bfilbuf(fb) : \
  -		    ((fb)->incnt--, (fb->flags & B_ASCII2EBCDIC)\
  -		    ?os_toebcdic[(unsigned char)*((fb)->inptr++)]:*((fb)->inptr++)) )
  -
  -#define ap_bputc(c, fb) ((((fb)->flags & (B_EOUT|B_WRERR|B_WR)) != B_WR || \
  -		     (fb)->outcnt == (fb)->bufsiz) ? ap_bflsbuf(c, (fb)) : \
  -		     ((fb)->outbase[(fb)->outcnt++] = (fb->flags & B_EBCDIC2ASCII)\
  -		     ?os_toascii[(unsigned char)c]:(c), 0))
   
  -#endif /*CHARSET_EBCDIC*/
  +/* XXX: this doesn't belong here... should be part of a generic spawning API in APR/NSPR
*/
   struct child_info {
   #ifdef WIN32
       /*
  
  
  
  1.2       +11 -417   apache-2.0/mpm/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/main/buff.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- buff.c	1999/06/18 18:39:29	1.1
  +++ buff.c	1999/06/18 19:20:48	1.2
  @@ -75,12 +75,6 @@
   #ifndef DEFAULT_BUFSIZE
   #define DEFAULT_BUFSIZE (4096)
   #endif
  -/* This must be enough to represent (DEFAULT_BUFSIZE - 3) in hex,
  - * plus two extra characters.
  - */
  -#ifndef CHUNK_HEADER_SIZE
  -#define CHUNK_HEADER_SIZE (5)
  -#endif
   
   
   /* bwrite()s of greater than this size can result in a large_write() call,
  @@ -219,37 +213,21 @@
       else
   	fb->inbase = NULL;
   
  -    /* overallocate so that we can put a chunk trailer of CRLF into this
  -     * buffer */
       if (flags & B_WR)
  -	fb->outbase = ap_palloc(p, fb->bufsiz + 2);
  +	fb->outbase = ap_palloc(p, fb->bufsiz);
       else
   	fb->outbase = NULL;
   
  -#ifdef CHARSET_EBCDIC
  -    fb->flags |= (flags & B_SOCKET) ? (B_EBCDIC2ASCII | B_ASCII2EBCDIC) : 0;
  -#endif /*CHARSET_EBCDIC*/
  -
       fb->inptr = fb->inbase;
   
       fb->incnt = 0;
       fb->outcnt = 0;
  -    fb->outchunk = -1;
       fb->error = NULL;
       fb->bytes_sent = 0;
   
       fb->fd = -1;
       fb->timeout = -1;
   
  -#ifdef B_SFIO
  -    fb->sf_in = NULL;
  -    fb->sf_out = NULL;
  -    fb->sf_in = sfnew(fb->sf_in, NIL(Void_t *),
  -		      (size_t) SF_UNBOUND, 0, SF_READ);
  -    fb->sf_out = sfnew(fb->sf_out, NIL(Void_t *),
  -		       (size_t) SF_UNBOUND, 1, SF_WRITE);
  -#endif
  -
       return fb;
   }
   
  @@ -298,105 +276,17 @@
   
   static int bflush_core(BUFF *fb);
   
  -/*
  - * Start chunked encoding.
  - *
  - * Note that in order for ap_bputc() to be an efficient macro we have to guarantee
  - * that start_chunk() has always been called on the buffer before we leave any
  - * routine in this file.  Said another way, if a routine here uses end_chunk()
  - * and writes something on the wire, then it has to call start_chunk() or set
  - * an error condition before returning.
  - */
  -static void start_chunk(BUFF *fb)
  -{
  -    if (fb->outchunk != -1) {
  -	/* already chunking */
  -	return;
  -    }
  -    if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) {
  -	/* unbuffered writes */
  -	return;
  -    }
   
  -    /* we need at least the header_len + at least 1 data byte
  -     * remember that we've overallocated fb->outbase so that we can always
  -     * fit the two byte CRLF trailer
  -     */
  -    if (fb->bufsiz - fb->outcnt < CHUNK_HEADER_SIZE + 1) {
  -	bflush_core(fb);
  -    }
  -    fb->outchunk = fb->outcnt;
  -    fb->outcnt += CHUNK_HEADER_SIZE;
  -}
  -
  -
   /*
  - * end a chunk -- tweak the chunk_header from start_chunk, and add a trailer
  - */
  -static void end_chunk(BUFF *fb)
  -{
  -    int i;
  -    unsigned char *strp;
  -
  -    if (fb->outchunk == -1) {
  -	/* not chunking */
  -	return;
  -    }
  -
  -    if (fb->outchunk + CHUNK_HEADER_SIZE == fb->outcnt) {
  -	/* nothing was written into this chunk, and we can't write a 0 size
  -	 * chunk because that signifies EOF, so just erase it
  -	 */
  -	fb->outcnt = fb->outchunk;
  -	fb->outchunk = -1;
  -	return;
  -    }
  -
  -    /* we know this will fit because of how we wrote it in start_chunk() */
  -    i = ap_snprintf((char *) &fb->outbase[fb->outchunk], CHUNK_HEADER_SIZE,
  -		"%x", fb->outcnt - fb->outchunk - CHUNK_HEADER_SIZE);
  -
  -    /* we may have to tack some trailing spaces onto the number we just wrote
  -     * in case it was smaller than our estimated size.  We've also written
  -     * a \0 into the buffer with ap_snprintf so we might have to put a
  -     * \r back in.
  -     */
  -    strp = &fb->outbase[fb->outchunk + i];
  -    while (i < CHUNK_HEADER_SIZE - 2) {
  -	*strp++ = ' ';
  -	++i;
  -    }
  -    *strp++ = '\015';
  -    *strp = '\012';
  -#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->outchunk = -1;
  -}
  -
  -
  -/*
    * Set a flag on (1) or off (0).
    */
   API_EXPORT(int) ap_bsetflag(BUFF *fb, int flag, int value)
   {
       if (value) {
   	fb->flags |= flag;
  -	if (flag & B_CHUNK) {
  -	    start_chunk(fb);
  -	}
       }
       else {
   	fb->flags &= ~flag;
  -	if (flag & B_CHUNK) {
  -	    end_chunk(fb);
  -	}
       }
       return value;
   }
  @@ -432,7 +322,7 @@
   #elif defined(O_NDELAY)
       fd_flags &= ~O_NDELAY;
       return fcntl(fd, F_SETFL, fd_flags);
  -#eli f defined(FNDELAY)
  +#elif defined(FNDELAY)
       fd_flags &= ~O_FNDELAY;
       return fcntl(fd, F_SETFL, fd_flags);
   #else
  @@ -454,14 +344,7 @@
    */
   
   
  -#if !defined (B_SFIO)
   #define saferead saferead_guts
  -#else
  -static int saferead(BUFF *fb, char *buf, int nbyte)
  -{
  -    return sfread(fb->sf_in, buf, nbyte);
  -}
  -#endif
   
   
   /* Test the descriptor and flush the output buffer if it looks like
  @@ -510,47 +393,10 @@
       return (rv);
   }
   
  -#ifdef B_SFIO
  -int bsfio_read(Sfio_t * f, char *buf, int nbyte, apache_sfio *disc)
  -{
  -    int rv;
  -    BUFF *fb = disc->buff;
  -
  -    rv = saferead_guts(fb, buf, nbyte, 0);
  -
  -    buf[rv] = '\0';
  -    f->next = 0;
  -
  -    return (rv);
  -}
  -
  -int bsfio_write(Sfio_t * f, char *buf, int nbyte, apache_sfio *disc)
  -{
  -    return ap_write(disc->buff, buf, nbyte);
  -}
  -
  -Sfdisc_t *bsfio_new(pool *p, BUFF *b)
  -{
  -    apache_sfio *disc;
  -
  -    if (!(disc = (apache_sfio *) ap_palloc(p, sizeof(apache_sfio))))
  -	            return (Sfdisc_t *) disc;
  -
  -    disc->disc.readf = (Sfread_f) bsfio_read;
  -    disc->disc.writef = (Sfwrite_f) bsfio_write;
  -    disc->disc.seekf = (Sfseek_f) NULL;
  -    disc->disc.exceptf = (Sfexcept_f) NULL;
  -    disc->buff = b;
   
  -    return (Sfdisc_t *) disc;
  -}
  -#endif
  -
  -
   /* A wrapper around saferead which does error checking and EOF checking
    * yeah, it's confusing, this calls saferead, which calls recvwithtimeout...
  - * and then there's the SFIO case.  Note that saferead takes care
  - * of EINTR.
  + * Note that saferead takes care of EINTR.
    */
   static int read_with_errors(BUFF *fb, void *buf, int nbyte)
   {
  @@ -570,9 +416,6 @@
    * Read up to nbyte bytes into buf.
    * If fewer than byte bytes are currently available, then return those.
    * Returns 0 for EOF, -1 for error.
  - * NOTE EBCDIC: The readahead buffer _always_ contains *unconverted* data.
  - * Only when the caller retrieves data from the buffer (calls bread)
  - * is a conversion done, if the conversion flag is set at that time.
    */
   API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte)
   {
  @@ -588,32 +431,18 @@
   	 * buffer from before we went unbuffered. */
   	if (fb->incnt) {
   	    i = (fb->incnt > nbyte) ? nbyte : fb->incnt;
  -#ifdef CHARSET_EBCDIC
  -	    if (fb->flags & B_ASCII2EBCDIC)
  -		ascii2ebcdic(buf, fb->inptr, i);
  -	    else
  -#endif /*CHARSET_EBCDIC*/
   	    memcpy(buf, fb->inptr, i);
   	    fb->incnt -= i;
   	    fb->inptr += i;
   	    return i;
   	}
   	i = read_with_errors(fb, buf, nbyte);
  -#ifdef CHARSET_EBCDIC
  -	if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC))
  -	    ascii2ebcdic(buf, buf, i);
  -#endif /*CHARSET_EBCDIC*/
   	return i;
       }
   
       nrd = fb->incnt;
   /* can we fill the buffer */
       if (nrd >= nbyte) {
  -#ifdef CHARSET_EBCDIC
  -	if (fb->flags & B_ASCII2EBCDIC)
  -	    ascii2ebcdic(buf, fb->inptr, nbyte);
  -	else
  -#endif /*CHARSET_EBCDIC*/
   	memcpy(buf, fb->inptr, nbyte);
   	fb->incnt = nrd - nbyte;
   	fb->inptr += nbyte;
  @@ -621,11 +450,6 @@
       }
   
       if (nrd > 0) {
  -#ifdef CHARSET_EBCDIC
  -	if (fb->flags & B_ASCII2EBCDIC)
  -	    ascii2ebcdic(buf, fb->inptr, nrd);
  -	else
  -#endif /*CHARSET_EBCDIC*/
   	memcpy(buf, fb->inptr, nrd);
   	nbyte -= nrd;
   	buf = nrd + (char *) buf;
  @@ -638,10 +462,6 @@
       if (nbyte >= fb->bufsiz) {
   /* read directly into caller's buffer */
   	i = read_with_errors(fb, buf, nbyte);
  -#ifdef CHARSET_EBCDIC
  -	if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC))
  -	    ascii2ebcdic(buf, buf, i);
  -#endif /*CHARSET_EBCDIC*/
   	if (i == -1) {
   	    return nrd ? nrd : -1;
   	}
  @@ -656,11 +476,6 @@
   	fb->incnt = i;
   	if (i > nbyte)
   	    i = nbyte;
  -#ifdef CHARSET_EBCDIC
  -	if (fb->flags & B_ASCII2EBCDIC)
  -	    ascii2ebcdic(buf, fb->inptr, i);
  -	else
  -#endif /*CHARSET_EBCDIC*/
   	memcpy(buf, fb->inptr, i);
   	fb->incnt -= i;
   	fb->inptr += i;
  @@ -721,7 +536,6 @@
   	}
   
   	ch = fb->inptr[i++];
  -#ifndef CHARSET_EBCDIC
   	if (ch == '\012') {	/* got LF */
   	    if (ct == 0)
   		buff[ct++] = '\n';
  @@ -734,22 +548,6 @@
   		i--;		/* no room for LF */
   	    break;
   	}
  -#else /* an EBCDIC machine: do the same, but convert to EBCDIC on the fly: */
  -	if (fb->flags & B_ASCII2EBCDIC)
  -	    ch = os_toebcdic[(unsigned char)ch];
  -	if (ch == os_toebcdic['\012']) {  /* 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'])
  -		buff[ct - 1] = '\n';
  -	    else if (ct < n - 1)
  -		buff[ct++] = '\n';
  -	    else
  -		i--;		/* no room for LF */
  -	    break;
  -	}
  -#endif
   	if (ct == n - 1) {
   	    i--;		/* push back ch */
   	    break;
  @@ -796,13 +594,7 @@
   	fb->incnt = i;
       }
   
  -#ifndef CHARSET_EBCDIC
       *buff = fb->inptr[0];
  -#else /*CHARSET_EBCDIC*/
  -    *buff = (fb->flags & B_ASCII2EBCDIC)
  -	     ? os_toebcdic[(unsigned char)fb->inptr[0]]
  -	     : fb->inptr[0];
  -#endif /*CHARSET_EBCDIC*/
       return 1;
   }
   
  @@ -873,42 +665,6 @@
   }
   
   
  -/*
  - * When doing chunked encodings we really have to write everything in the
  - * chunk before proceeding onto anything else.  This routine either writes
  - * nbytes and returns 0 or returns -1 indicating a failure.
  - *
  - * This is *seriously broken* if used on a non-blocking fd.  It will poll.
  - *
  - * Deals with calling doerror and setting bytes_sent.
  - */
  -static int write_it_all(BUFF *fb, const void *buf, int nbyte)
  -{
  -    int i;
  -
  -    if (fb->flags & (B_WRERR | B_EOUT))
  -	return -1;
  -
  -    while (nbyte > 0) {
  -	i = sendwithtimeout(fb->fd, buf, nbyte, fb->timeout);
  -	if (i < 0) {
  -	    if (errno != EAGAIN && errno != EINTR) {
  -		doerror(fb, B_WR);
  -		return -1;
  -	    }
  -	}
  -	else {
  -	    nbyte -= i;
  -	    buf = i + (const char *) buf;
  -	    fb->bytes_sent += i;
  -	}
  -	if (fb->flags & B_EOUT)
  -	    return -1;
  -    }
  -    return 0;
  -}
  -
  -
   #ifndef NO_WRITEV
   /* Similar to previous, but uses writev.  Note that it modifies vec.
    * return 0 if successful, -1 otherwise.
  @@ -980,63 +736,7 @@
   }
   
   
  -/*
  - * A hook to write() that deals with chunking. This is really a protocol-
  - * level issue, but we deal with it here because it's simpler; this is
  - * an interim solution pending a complete rewrite of all this stuff in
  - * 2.0, using something like sfio stacked disciplines or BSD's funopen().
  - *
  - * Can be used on non-blocking descriptors, but only if they're not chunked.
  - * Deals with doerror() and bytes_sent.
  - */
  -static int bcwrite(BUFF *fb, const void *buf, int nbyte)
  -{
  -    char chunksize[16];		/* Big enough for practically anything */
   #ifndef NO_WRITEV
  -    struct iovec vec[3];
  -#endif
  -
  -    if (fb->flags & (B_WRERR | B_EOUT))
  -	return -1;
  -
  -    if (!(fb->flags & B_CHUNK)) {
  -	return write_with_errors(fb, buf, nbyte);
  -    }
  -
  -#ifdef NO_WRITEV
  -    /* without writev() this has poor performance, too bad */
  -
  -    ap_snprintf(chunksize, sizeof(chunksize), "%x\015\012", nbyte);
  -#ifdef CHARSET_EBCDIC
  -    /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
  -    ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
  -#endif /*CHARSET_EBCDIC*/
  -    if (write_it_all(fb, chunksize, strlen(chunksize), 0) == -1)
  -	return -1;
  -    if (write_it_all(fb, buf, nbyte, 0) == -1)
  -	return -1;
  -    if (write_it_all(fb, "\015\012", 2, 0) == -1)
  -	return -1;
  -    return nbyte;
  -#else
  -    vec[0].iov_base = chunksize;
  -    vec[0].iov_len = ap_snprintf(chunksize, sizeof(chunksize), "%x\015\012",
  -				 nbyte);
  -#ifdef CHARSET_EBCDIC
  -    /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
  -    ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
  -#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_len = 2;
  -
  -    return writev_it_all(fb, vec, (sizeof(vec) / sizeof(vec[0]))) ? -1 : nbyte;
  -#endif
  -}
  -
  -
  -#ifndef NO_WRITEV
   /*
    * Used to combine the contents of the fb buffer, and a large buffer
    * passed in.
  @@ -1045,47 +745,21 @@
   {
       struct iovec vec[4];
       int nvec;
  -    char chunksize[16];
   
  -    /* it's easiest to end the current chunk */
  -    if (fb->flags & B_CHUNK) {
  -	end_chunk(fb);
  -    }
       nvec = 0;
       if (fb->outcnt > 0) {
   	vec[nvec].iov_base = (void *) fb->outbase;
   	vec[nvec].iov_len = fb->outcnt;
   	++nvec;
  -    }
  -    if (fb->flags & B_CHUNK) {
  -	vec[nvec].iov_base = chunksize;
  -	vec[nvec].iov_len = ap_snprintf(chunksize, sizeof(chunksize),
  -					"%x\015\012", nbyte);
  -#ifdef CHARSET_EBCDIC
  -    /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII */
  -	ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
  -#endif /*CHARSET_EBCDIC*/
  -	++nvec;
  -	vec[nvec].iov_base = (void *) buf;
  -	vec[nvec].iov_len = nbyte;
  -	++nvec;
  -	vec[nvec].iov_base = "\015\012";
  -	vec[nvec].iov_len = 2;
  -	++nvec;
  -    }
  -    else {
  -	vec[nvec].iov_base = (void *) buf;
  -	vec[nvec].iov_len = nbyte;
  -	++nvec;
       }
  +    vec[nvec].iov_base = (void *) buf;
  +    vec[nvec].iov_len = nbyte;
  +    ++nvec;
   
       fb->outcnt = 0;
       if (writev_it_all(fb, vec, nvec)) {
   	return -1;
       }
  -    else if (fb->flags & B_CHUNK) {
  -	start_chunk(fb);
  -    }
       return nbyte;
   }
   #endif
  @@ -1100,37 +774,15 @@
    */
   API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte)
   {
  -    int i, nwr, useable_bufsiz;
  -#ifdef CHARSET_EBCDIC
  -    static char *cbuf = NULL;
  -    static int csize = 0;
  -#endif /*CHARSET_EBCDIC*/
  +    int i, nwr;
   
       if (fb->flags & (B_WRERR | B_EOUT))
   	return -1;
       if (nbyte == 0)
   	return 0;
   
  -#ifdef CHARSET_EBCDIC
  -    if (ap_bgetflag(fb, B_EBCDIC2ASCII)) {
  -        if (nbyte > csize) {
  -            if (cbuf != NULL)
  -                free(cbuf);
  -            cbuf = malloc(csize = nbyte+HUGE_STRING_LEN);
  -            if (cbuf == NULL) {
  -                fprintf(stderr, "Ouch!  Out of memory in ap_bwrite()!\n");
  -                csize = 0;
  -            }
  -        }
  -        ebcdic2ascii((cbuf) ? cbuf : (void*)buf, buf, nbyte);
  -        buf = (cbuf) ? cbuf : buf;
  -    }
  -#endif /*CHARSET_EBCDIC*/
  -
       if (!(fb->flags & B_WR)) {
  -/* unbuffered write -- have to use bcwrite since we aren't taking care
  - * of chunking any other way */
  -	return bcwrite(fb, buf, nbyte);
  +	return write_with_errors(fb, buf, nbyte);
       }
   
   #ifndef NO_WRITEV
  @@ -1168,18 +820,6 @@
   	}
   
   /* the buffer must be full */
  -	if (fb->flags & B_CHUNK) {
  -	    end_chunk(fb);
  -	    /* it is just too painful to try to re-cram the buffer while
  -	     * chunking
  -	     */
  -	    if (write_it_all(fb, fb->outbase, fb->outcnt) == -1) {
  -		/* we cannot continue after a chunked error */
  -		return -1;
  -	    }
  -	    fb->outcnt = 0;
  -	    break;
  -	}
   	i = write_with_errors(fb, fb->outbase, fb->outcnt);
   	if (i <= 0) {
   	    return nwr ? nwr : -1;
  @@ -1200,21 +840,10 @@
   	    return -1;
       }
   /* we have emptied the file buffer. Now try to write the data from the
  - * original buffer until there is less than bufsiz left.  Note that we
  - * use bcwrite() to do this for us, it will do the chunking so that
  - * we don't have to dink around building a chunk in our own buffer.
  - *
  - * Note also that bcwrite never does a partial write if we're chunking,
  - * so we're guaranteed to either end in an error state, or make it
  - * out of this loop and call start_chunk() below.
  - *
  - * Remember we may not be able to use the entire buffer if we're
  - * chunking.
  + * original buffer until there is less than bufsiz left.
    */
  -    useable_bufsiz = fb->bufsiz;
  -    if (fb->flags & B_CHUNK) useable_bufsiz -= CHUNK_HEADER_SIZE;
  -    while (nbyte >= useable_bufsiz) {
  -	i = bcwrite(fb, buf, nbyte);
  +    while (nbyte >= fb->bufsiz) {
  +	i = write_with_errors(fb, buf, nbyte);
   	if (i <= 0) {
   	    return nwr ? nwr : -1;
   	}
  @@ -1228,8 +857,6 @@
       }
   /* copy what's left to the file buffer */
       fb->outcnt = 0;
  -    if (fb->flags & B_CHUNK)
  -	start_chunk(fb);
       if (nbyte > 0)
   	memcpy(fb->outbase + fb->outcnt, buf, nbyte);
       fb->outcnt += nbyte;
  @@ -1280,15 +907,8 @@
       if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR)
   	return -1;
   
  -    if (fb->flags & B_CHUNK)
  -	end_chunk(fb);
  -
       ret = bflush_core(fb);
   
  -    if (ret == 0 && (fb->flags & B_CHUNK)) {
  -	start_chunk(fb);
  -    }
  -
       return ret;
   }
   
  @@ -1315,11 +935,6 @@
       fb->flags |= B_EOF | B_EOUT;
       fb->fd = -1;
   
  -#ifdef B_SFIO
  -    sfclose(fb->sf_in);
  -    sfclose(fb->sf_out);
  -#endif
  -
       if (rc1 != 0)
   	return rc1;
       return rc2;
  @@ -1383,13 +998,6 @@
       struct bprintf_data *b = (struct bprintf_data *)vbuff;
       BUFF *fb = b->fb;
   
  -#ifdef CHARSET_EBCDIC
  -    /* Characters were pushed into the buffer without conversion. Do it now */
  -    if (fb->flags & B_EBCDIC2ASCII)
  -        ebcdic2ascii(&fb->outbase[fb->outcnt],
  -		     &fb->outbase[fb->outcnt],
  -		     b->vbuff.curpos - (char *)&fb->outbase[fb->outcnt]);
  -#endif /*CHARSET_EBCDIC*/
       fb->outcnt += b->vbuff.curpos - (char *)&fb->outbase[fb->outcnt];
       if (fb->outcnt == fb->bufsiz) {
   	if (ap_bflush(fb)) {
  @@ -1417,13 +1025,6 @@
       res = ap_vformatter(bprintf_flush, &b.vbuff, fmt, ap);
       va_end(ap);
       if (res != -1) {
  -#ifdef CHARSET_EBCDIC
  -	/* Characters were pushed into the buffer without conversion. Do it now */
  -	if (fb->flags & B_EBCDIC2ASCII)
  -	    ebcdic2ascii(&fb->outbase[fb->outcnt],
  -			 &fb->outbase[fb->outcnt],
  -			 b.vbuff.curpos - (char *)&fb->outbase[fb->outcnt]);
  -#endif /*CHARSET_EBCDIC*/
   	fb->outcnt += b.vbuff.curpos - (char *)&fb->outbase[fb->outcnt];
       }
       return res;
  @@ -1442,13 +1043,6 @@
       b.fb = fb;
       res = ap_vformatter(bprintf_flush, &b.vbuff, fmt, ap);
       if (res != -1) {
  -#ifdef CHARSET_EBCDIC
  -	/* Characters were pushed into the buffer without conversion. Do it now */
  -	if (fb->flags & B_EBCDIC2ASCII)
  -	    ebcdic2ascii(&fb->outbase[fb->outcnt],
  -			 &fb->outbase[fb->outcnt],
  -			 b.vbuff.curpos - (char *)&fb->outbase[fb->outcnt]);
  -#endif /*CHARSET_EBCDIC*/
   	fb->outcnt += b.vbuff.curpos - (char *)&fb->outbase[fb->outcnt];
       }
       return res;
  
  
  
  1.2       +4 -0      apache-2.0/mpm/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/mpm/src/main/http_protocol.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- http_protocol.c	1999/06/18 18:39:30	1.1
  +++ http_protocol.c	1999/06/18 19:20:49	1.2
  @@ -1551,8 +1551,10 @@
       r->sent_bodyct = 1;         /* Whatever follows is real body stuff... */
   
       /* Set buffer flags for the body */
  +#if 0	/* TODO: implemented chunked layer */
       if (r->chunked)
           ap_bsetflag(r->connection->client, B_CHUNK, 1);
  +#endif
   #ifdef CHARSET_EBCDIC
       if (!convert)
           ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert);
  @@ -1571,7 +1573,9 @@
            * Turn off chunked encoding --- we can only do this once.
            */
           r->chunked = 0;
  +#if 0	/* TODO: implemented chunked layer */
           ap_bsetflag(r->connection->client, B_CHUNK, 0);
  +#endif
   
           ap_rputs("0\015\012", r);
           /* If we had footer "headers", we'd send them now */
  
  
  

Mime
View raw message