brian 96/11/13 23:35:51
Modified: src http_protocol.c
Log:
Submitted by: Alexei Kosut
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
Revision Changes Path
1.75 +9 -6 apache/src/http_protocol.c
Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -C3 -r1.74 -r1.75
*** http_protocol.c 1996/11/10 09:16:10 1.74
--- http_protocol.c 1996/11/14 07:35:49 1.75
***************
*** 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);
}