Skip to content

Commit 27f1508

Browse files
author
Nick Kew
committed
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
1 parent 6431c83 commit 27f1508

4 files changed

Lines changed: 24 additions & 0 deletions

File tree

CHANGES

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Changes with Apache 2.3.5
44

5+
*) Core HTTP: disable keepalive when the Client has sent
6+
Expect: 100-continue
7+
but we respond directly with a non-100 response.
8+
Keepalive here led to data from clients continuing being treated as
9+
a new request.
10+
PR 47087 [Nick Kew]
11+
512
Changes with Apache 2.3.4
613

714
*) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex,

modules/http/http_filters.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ apr_status_t ap_http_filter(ap_filter_t *f, apr_bucket_brigade *b,
329329
char *tmp;
330330
int len;
331331

332+
/* if we send an interim response, we're no longer
333+
* in a state of expecting one.
334+
*/
335+
f->r->expecting_100 = 0;
332336
tmp = apr_pstrcat(f->r->pool, AP_SERVER_PROTOCOL, " ",
333337
ap_get_status_line(HTTP_CONTINUE), CRLF CRLF,
334338
NULL);

modules/http/http_protocol.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
180180
* body should use the HTTP/1.1 chunked transfer-coding. In English,
181181
*
182182
* IF we have not marked this connection as errored;
183+
* and the client isn't expecting 100-continue (PR47087 - more
184+
* input here could be the client continuing when we're
185+
* closing the request).
183186
* and the response body has a defined length due to the status code
184187
* being 304 or 204, the request method being HEAD, already
185188
* having defined Content-Length or Transfer-Encoding: chunked, or
@@ -201,6 +204,7 @@ AP_DECLARE(int) ap_set_keepalive(request_rec *r)
201204
* Note that the condition evaluation order is extremely important.
202205
*/
203206
if ((r->connection->keepalive != AP_CONN_CLOSE)
207+
&& !r->expecting_100
204208
&& ((r->status == HTTP_NOT_MODIFIED)
205209
|| (r->status == HTTP_NO_CONTENT)
206210
|| r->header_only

server/protocol.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ AP_DECLARE(void) ap_send_interim_response(request_rec *r, int send_headers)
16821682
{
16831683
hdr_ptr x;
16841684
char *status_line = NULL;
1685+
request_rec *rr;
16851686

16861687
if (r->proto_num < 1001) {
16871688
/* 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)
17011702
return;
17021703
}
17031704

1705+
/* if we send an interim response, we're no longer in a state of
1706+
* expecting one. Also, this could feasibly be in a subrequest,
1707+
* so we need to propagate the fact that we responded.
1708+
*/
1709+
for (rr = r; rr != NULL; rr = rr->main) {
1710+
rr->expecting_100 = 0;
1711+
}
1712+
17041713
status_line = apr_pstrcat(r->pool, AP_SERVER_PROTOCOL, " ", r->status_line, CRLF, NULL);
17051714
ap_xlate_proto_to_ascii(status_line, strlen(status_line));
17061715

0 commit comments

Comments
 (0)