return mb;
}
+HttpReplyPointer
+HttpReply::MakeConnectionEstablished() {
+
+ HttpReplyPointer rep(new HttpReply);
+ rep->sline.set(Http::ProtocolVersion(), Http::scOkay, "Connection established");
+ return rep;
+}
+
HttpReply *
HttpReply::make304() const
{
/** \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;
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)
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
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;
*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;
}
}