From: Eduard Bagdasaryan Date: Fri, 20 Sep 2019 11:15:21 +0000 (+0000) Subject: Set ALE::reply to the 200 (Connection established) (#476) X-Git-Tag: SQUID_5_0_1~40 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea55799d6e44a0979070cfbfdebaa807921beb93;p=thirdparty%2Fsquid.git Set ALE::reply to the 200 (Connection established) (#476) ... thus addressing a TODO. Lack of reply may cause "ACL is used in context without an HTTP response" errors in some contexts. These contexts (if any) should be fixed separately. --- diff --git a/src/HttpReply.cc b/src/HttpReply.cc index c63fccdf30..38ea4638a2 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -116,6 +116,14 @@ HttpReply::pack() const return mb; } +HttpReplyPointer +HttpReply::MakeConnectionEstablished() { + + HttpReplyPointer rep(new HttpReply); + rep->sline.set(Http::ProtocolVersion(), Http::scOkay, "Connection established"); + return rep; +} + HttpReply * HttpReply::make304() const { diff --git a/src/HttpReply.h b/src/HttpReply.h index 6f0be1ee9b..a0bf2854b6 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -81,6 +81,9 @@ public: /** \return a ready to use mem buffer with a packed reply */ MemBuf *pack() const; + /// construct and return an HTTP/200 (Connection Established) response + static HttpReplyPointer MakeConnectionEstablished(); + /** construct a 304 reply and return it */ HttpReply *make304() const; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 5297f8a2db..7760d1db96 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1585,10 +1585,6 @@ ClientHttpRequest::sslBumpEstablish(Comm::Flag errflag) return; } - // We lack HttpReply which logRequest() uses to log the status code. - // TODO: Use HttpReply instead of the "200 Connection established" string. - al->http.code = 200; - #if USE_AUTH // Preserve authentication info for the ssl-bumped request if (request->auth_user_request != NULL) @@ -1617,10 +1613,13 @@ ClientHttpRequest::sslBumpStart() return; } + al->reply = HttpReply::MakeConnectionEstablished(); + + const auto mb = al->reply->pack(); // send an HTTP 200 response to kick client SSL negotiation // TODO: Unify with tunnel.cc and add a Server(?) header - static const char *const conn_established = "HTTP/1.1 200 Connection established\r\n\r\n"; - Comm::Write(getConn()->clientConnection, conn_established, strlen(conn_established), bumpCall, NULL); + Comm::Write(getConn()->clientConnection, mb, bumpCall); + delete mb; } #endif diff --git a/src/tunnel.cc b/src/tunnel.cc index 4c3d9e1672..5ef19aae59 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -252,8 +252,6 @@ public: void copyServerBytes(); }; -static const char *const conn_established = "HTTP/1.1 200 Connection established\r\n\r\n"; - static ERCB tunnelErrorComplete; static CLCB tunnelServerClosed; static CLCB tunnelClientClosed; @@ -863,7 +861,10 @@ TunnelStateData::notePeerReadyToShovel() *status_ptr = Http::scOkay; AsyncCall::Pointer call = commCbCall(5,5, "tunnelConnectedWriteDone", CommIoCbPtrFun(tunnelConnectedWriteDone, this)); - client.write(conn_established, strlen(conn_established), call, nullptr); + al->reply = HttpReply::MakeConnectionEstablished(); + const auto mb = al->reply->pack(); + client.write(mb->content(), mb->contentSize(), call, mb->freeFunc()); + delete mb; } }