httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexei Kosut <ako...@nueva.pvt.k12.ca.us>
Subject fix to get_client_block for chunked input
Date Thu, 14 Nov 1996 06:44:08 GMT
Here's a patch that provides a number of fixes to chunked
transfer-coded input when using get_client_block:

1) Correctly works with 1-byte reads (like content-lengthed reads,
which was fixed a week or so ago, this was not working.)

2) Fix "footer" reading. It now just calls get_mime_headers(), which
should work. This way, they're accessible to the server, as they
should be, though (unfortunately?) mod_cgi calls get_client_block too
late to pass it on to the CGI script. Unless anyone knows a way to
modify the environment of a child after you've forked it.

It also adds a few comments (there was one part it took me five
minutes to remember what the heck it was doing... and I wrote it. So I
figured I'd better throw in a comment). Anyhow, I think it's important
to make this work right, since it's an integral part of HTTP/1.1.

Oh, and someone asked about testing chunked input (I forget who). As
far as I know, no major clients support it. Some of the less-popular
ones might, though. The emacs and lisp ones, maybe, or the Jigsaw
client-thingy. I just use telnet and type things in manually.

At any rate, here's the patch:

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.74
diff -c -r1.74 http_protocol.c
*** http_protocol.c	1996/11/10 09:16:10	1.74
--- http_protocol.c	1996/11/14 06:36:52
***************
*** 1098,1103 ****
--- 1098,1104 ----
  	    return BAD_REQUEST;
  	}
  	r->read_chunked = 1;
+ 	r->remaining = 0;
      }
      else {
  	if (!lenp) {
***************
*** 1167,1187 ****
      if (len_to_read == 0) {
  	len_to_read = rd_chunk_size(r->connection->client);
  	if (len_to_read == 0) {
! 	    /* Skip over any "footers" */
! 	    do c = bgets(buffer, bufsiz, r->connection->client);
! 	    while ((c > 0) && (*buffer != '\015') && (*buffer != '\012'));
  	    return 0;
  	}
      }
!     if (len_to_read >= bufsiz) {
! 	r->remaining = len_to_read - bufsiz - 1;
! 	len_to_read = bufsiz - 1;
      }
      else
  	r->remaining = 0;
      
      len_read = bread(r->connection->client, buffer, len_to_read);
      if (r->remaining == 0) {
  	do c = bgetc (r->connection->client);
  	while (c != '\n' && c != EOF);
      }
--- 1168,1190 ----
      if (len_to_read == 0) {
  	len_to_read = rd_chunk_size(r->connection->client);
  	if (len_to_read == 0) {
! 	    /* Read any footers - the module may not notice them,
! 	     * but they're there, and so we read them */
! 	    get_mime_headers(r);
  	    return 0;
  	}
      }
!     if (len_to_read > bufsiz) {
! 	r->remaining = len_to_read - bufsiz;
! 	len_to_read = bufsiz;
      }
      else
  	r->remaining = 0;
      
      len_read = bread(r->connection->client, buffer, len_to_read);
      if (r->remaining == 0) {
+ 	/* Read the newline at the end of the chunk
+ 	 * (and any other garbage that might be present) */
  	do c = bgetc (r->connection->client);
  	while (c != '\n' && c != EOF);
      }


-- 
________________________________________________________________________
Alexei Kosut <akosut@nueva.pvt.k12.ca.us>      The Apache HTTP Server
URL: http://www.nueva.pvt.k12.ca.us/~akosut/   http://www.apache.org/


Mime
View raw message