You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ed Korthof <ed...@bitmechanic.com> on 1998/07/30 07:09:53 UTC
[PATCH] empty response w/ 414
Hiya --
A while ago, I contributed a patch to respond w/ 414 error codes (and 400
for screwy mime headers) when appropriate. Jim Gettys (jg@pa.dec.com)
recently contacted me about 414s -- currently, though the error is logged,
no response is recieved. (This was probably the case when it was
initially commited as well, though I'm not certain.) Jim indicated that
this is in connection to HTTP/1.1 compliance.
My apologies if this has already been discussed; he sent the mail late
this month (I got it today), and I checked out the archive for this month,
without finding any relevant posts.
So, after some debugging, I found one thing which makes this work
correctly is to suck up the request data, then call "ap_bflush" after
calling "ap_die". Ordinarily, this isn't required, since when ap_die is
called at most other points, ap_process_request has been called on this
request_rec, and http_request.c takes care of this.
In this case, because the request doesn't get read correctly, read_request
returns null, and none of the later processing goes on.
Other than the fact that it seems to work correctly in my tests, I don't
know if this is the right way to fix things (or if other things are
needed). Since this is an error condition, and the connection should be
closed right after this, I'm guessing this is reasonable.
So anyway, I've included a patch (against 1.3.1) which fixes this by
calling "ap_bflush" when read_request is handling an error. I can
certainly rewrite this so that read_request would return something other
than NULL, and the call to ap_bflush (as well as sucking up any remaining
client request data) would occur in http_request.c -- but it would require
complicating the logic in http_request.c at least a little. I did it this
way because it required the fewest changes to the code.
There's one other place in http_protocol where ap_die is called, and a
call to ap_bflush might be appropriate (after calling the
post-read-request API functions), but I don't know about that section of
code or if such a thing is appropriate.
Thanks for Apache, btw. :) I'm sure I've said that before, but it still
holds.
Ed, who now helps with Apache-JServ, a Java servlet engine designed to
work w/ Apache
-----
*** http_protocol.c.orig Wed Jul 29 15:29:23 1998
--- http_protocol.c Wed Jul 29 21:55:14 1998
***************
*** 666,672 ****
r->status = HTTP_OK;
}
r->request_time = time(NULL);
ap_die (HTTP_REQUEST_URI_TOO_LARGE, r);
! return 0;
}
--- 666,681 ----
r->status = HTTP_OK;
}
+ /* pull data from the client first. */
+ ap_bnonblock(conn->client, B_RD);
+ while ((len = getline(l, HUGE_STRING_LEN, conn->client, 0)) >= 0) {
+ if (ap_bgetflag(conn->client, B_EOF)) {
+ break;
+ }
+ }
+
r->request_time = time(NULL);
ap_die (HTTP_REQUEST_URI_TOO_LARGE, r);
! ap_bflush(conn->client);
! return 0;
}
***************
*** 732,736 ****
--- 741,754 ----
r->status = HTTP_OK;
+ /* pull data from the client first. */
+ ap_bnonblock(c->client, B_RD);
+ while ((len = getline(field, MAX_STRING_LEN, c->client, 0)) >= 0) {
+ if (ap_bgetflag(c->client, B_EOF)) {
+ break;
+ }
+ }
+
ap_die (HTTP_BAD_REQUEST, r);
+ ap_bflush(c->client);
return;
}
-----