]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Set ALE::reply to the 200 (Connection established) (#476)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 20 Sep 2019 11:15:21 +0000 (11:15 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 21 Sep 2019 10:21:58 +0000 (10:21 +0000)
... 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.

src/HttpReply.cc
src/HttpReply.h
src/client_side_request.cc
src/tunnel.cc

index c63fccdf30382dec89ef8c7a534696426e02f3b9..38ea4638a2bee78fd705bce9fcbd5f2e3c1b4f6f 100644 (file)
@@ -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
 {
index 6f0be1ee9bab4569ea564eefc69f6774cbbd7592..a0bf2854b69e9a3ad33b324b8a4aa1f076ba3124 100644 (file)
@@ -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;
 
index 5297f8a2dbda5dac6474254c50431761e2ef64bb..7760d1db96ec387b3837db58463970879b807cdc 100644 (file)
@@ -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
index 4c3d9e1672df0abbb2389114259f88c85eb1b293..5ef19aae59824cf322133deb80d1d9d1c821f0da 100644 (file)
@@ -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;
     }
 }