1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

Don't keepalive when we send a non-100 response while Client is expecting 100

and may be feeding us continuation data.
PR 47087


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@888310 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nick Kew
2009-12-08 10:22:56 +00:00
parent b310db9324
commit 33b33d1987
4 changed files with 24 additions and 0 deletions

View File

@@ -2,6 +2,13 @@
Changes with Apache 2.3.5 Changes with Apache 2.3.5
*) Core HTTP: disable keepalive when the Client has sent
Expect: 100-continue
but we respond directly with a non-100 response.
Keepalive here led to data from clients continuing being treated as
a new request.
PR 47087 [Nick Kew]
Changes with Apache 2.3.4 Changes with Apache 2.3.4
*) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex, *) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex,

View File

@@ -329,6 +329,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
char *tmp; char *tmp;
int len; int len;
/* if we send an interim response, we're no longer
* in a state of expecting one.
*/
f->r->expecting_100 = 0;
tmp = apr_pstrcat(f->r->pool, AP_SERVER_PROTOCOL, " ", tmp = apr_pstrcat(f->r->pool, AP_SERVER_PROTOCOL, " ",
ap_get_status_line(HTTP_CONTINUE), CRLF CRLF, ap_get_status_line(HTTP_CONTINUE), CRLF CRLF,
NULL); NULL);

View File

@@ -180,6 +180,9 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
* body should use the HTTP/1.1 chunked transfer-coding. In English, * body should use the HTTP/1.1 chunked transfer-coding. In English,
* *
* IF we have not marked this connection as errored; * IF we have not marked this connection as errored;
* and the client isn't expecting 100-continue (PR47087 - more
* input here could be the client continuing when we're
* closing the request).
* and the response body has a defined length due to the status code * and the response body has a defined length due to the status code
* being 304 or 204, the request method being HEAD, already * being 304 or 204, the request method being HEAD, already
* having defined Content-Length or Transfer-Encoding: chunked, or * having defined Content-Length or Transfer-Encoding: chunked, or
@@ -201,6 +204,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
* Note that the condition evaluation order is extremely important. * Note that the condition evaluation order is extremely important.
*/ */
if ((r->connection->keepalive != AP_CONN_CLOSE) if ((r->connection->keepalive != AP_CONN_CLOSE)
&& !r->expecting_100
&& ((r->status == HTTP_NOT_MODIFIED) && ((r->status == HTTP_NOT_MODIFIED)
|| (r->status == HTTP_NO_CONTENT) || (r->status == HTTP_NO_CONTENT)
|| r->header_only || r->header_only

View File

@@ -1682,6 +1682,7 @@ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers)
{ {
hdr_ptr x; hdr_ptr x;
char *status_line = NULL; char *status_line = NULL;
request_rec *rr;
if (r->proto_num < 1001) { if (r->proto_num < 1001) {
/* don't send interim response to HTTP/1.0 Client */ /* don't send interim response to HTTP/1.0 Client */
@@ -1701,6 +1702,14 @@ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers)
return; return;
} }
/* if we send an interim response, we're no longer in a state of
* expecting one. Also, this could feasibly be in a subrequest,
* so we need to propagate the fact that we responded.
*/
for (rr = r; rr != NULL; rr = rr->main) {
rr->expecting_100 = 0;
}
status_line = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", r->status_line, CRLF, NULL); status_line = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", r->status_line, CRLF, NULL);
ap_xlate_proto_to_ascii(status_line, strlen(status_line)); ap_xlate_proto_to_ascii(status_line, strlen(status_line));