From 310afc6ccd27fb8734fe1a267f94ea92f82bad99 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Thu, 22 Jun 2006 04:37:49 +0000 Subject: [PATCH] ICAP bug: request satisfaction mode was not working. The presence of an HTTP body in the ICAP reply was assumed to be an HTTP request body, rather than possibly a response body. --- src/ICAP/ICAPClientReqmodPrecache.cc | 16 +++++++++++++--- src/client_side_request.cc | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ICAP/ICAPClientReqmodPrecache.cc b/src/ICAP/ICAPClientReqmodPrecache.cc index 0b4507c6db..42853b6a71 100644 --- a/src/ICAP/ICAPClientReqmodPrecache.cc +++ b/src/ICAP/ICAPClientReqmodPrecache.cc @@ -148,10 +148,20 @@ void ICAPClientReqmodPrecache::noteSourceProgress(MsgPipe *p) //tell ClientHttpRequest to store a fresh portion of the adapted response if (p->data->body->hasContent()) { + /* + * NOTE: req will be NULL if this is a "request satisfaction" + * ICAP reply. In other words, the ICAP REQMOD reply may + * contain an HTTP response, in which case we'll have a body, but + * adapted->data->header will be an HttpReply, not an HttpRequest. + */ HttpRequest *req = dynamic_cast(adapted->data->header); - assert(req); - debugs(32,3,HERE << "notifying body_reader, contentSize() = " << p->data->body->contentSize()); - req->body_reader->notify(p->data->body->contentSize()); + + if (req) { + debugs(32,3,HERE << "notifying body_reader, contentSize() = " << p->data->body->contentSize()); + req->body_reader->notify(p->data->body->contentSize()); + } else { + http->takeAdaptedBody(adapted->data->body); + } } } diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 5a2f1a9cc3..0193135134 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.70 2006/06/05 18:57:08 serassio Exp $ + * $Id: client_side_request.cc,v 1.71 2006/06/21 22:37:49 wessels Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -1252,6 +1252,9 @@ ClientHttpRequest::takeAdaptedBody(MemBuf *buf) storeEntry()->write(StoreIOBuffer(buf, request_satisfaction_offset)); request_satisfaction_offset += buf->contentSize(); buf->consume(buf->contentSize()); // consume everything written + } else { + debug(85,0)("Unexpected call to takeAdaptedBody when " + "not in request_satisfaction_mode"); } } -- 2.47.3