31 isHttpsServer(beHttpsServer)
55 TimeoutDialer,
this, Http1::Server::requestTimeout);
63 if (!handleRequestBodyData())
67 if (!
isOpen() || stoppedReceiving())
78 preservingClientData_ = shouldPreserveClientData();
83 if (!parser_ || !parser_->needsMoreData())
99 if (context->flags.parsed_ok == 0) {
100 debugs(33, 2,
"Invalid Request");
103 switch (parser_->parseStatusCode) {
115 if (parser_->method() ==
METHOD_NONE || parser_->requestUri().length() == 0)
125 const char * requestErrorBytes = inBuf.c_str();
126 if (!tunnelOnError(errPage)) {
127 setReplyError(context, request, errPage, parser_->parseStatusCode, requestErrorBytes);
137 mx->tcpClient = clientConnection;
140 debugs(33, 5,
"Invalid URL: " << http->
uri);
144 const char * requestErrorBytes = inBuf.c_str();
156 if ( (parser_->messageProtocol().major == 0 && parser_->messageProtocol().minor != 9) ||
157 (parser_->messageProtocol().major > 1) ) {
159 debugs(33, 5,
"Unsupported HTTP version discovered. :\n" << parser_->messageProtocol());
163 const char * requestErrorBytes =
nullptr;
172 if (parser_->messageProtocol().major >= 1 && !request->
parseHeader(*parser_.getRaw())) {
173 debugs(33, 5,
"Failed to parse request headers:\n" << parser_->mimeHeader());
176 const char * requestErrorBytes =
nullptr;
206 quitAfterError(request.
getRaw());
207 if (!context->connRegistered()) {
208 debugs(33, 2,
"Client stream deregister it self, nothing to do");
209 clientConnection->close();
216 repContext->
setReplyToError(requestError, errStatusCode, context->http->uri,
this,
nullptr, requestErrorBytes,
nullptr);
218 assert(context->http->out.offset == 0);
225 debugs(33, 5,
"Body Continuation written");
232 const auto context = pipeline.back();
233 const auto request = (context && context->http) ? context->http->request :
nullptr;
243 if (!buildHttpRequest(context))
251 const bool supportedExpect = (expect.
caseCmp(
"100-continue") == 0);
252 if (!supportedExpect) {
254 quitAfterError(request.
getRaw());
260 this, request.
getRaw(),
nullptr,
nullptr);
261 assert(context->http->out.offset == 0);
269 bodyContinuationCheck.
al = http->
al;
272 debugs(33, 5,
"Body Continuation forced");
292 stopReceiving(
"virgin request body consumer aborted");
300 Must(context !=
nullptr);
302 Must(http !=
nullptr);
309 !context->startOfOutput();
310 const bool responseFinishedOrFailed = !rep &&
311 !receivedData.
data &&
313 if (responseFinishedOrFailed && !mustSendLastChunk) {
314 context->writeComplete(0);
318 if (!context->startOfOutput()) {
319 context->sendBody(receivedData);
324 context->sendStartOfMessage(rep, receivedData);
331 Must(context !=
nullptr);
335 if (context->reply) {
336 debugs(11, 2,
"drop 1xx made late by " << context->reply);
354 if (switching && upgradeHeader.
size()) {
366 debugs(11, 2,
"HTTP Client " << clientConnection);
367 debugs(11, 2,
"HTTP Client CONTROL MSG:\n---------\n" << mb->
buf <<
"\n----------");
378 const auto context = pipeline.front();
380 const auto http = context->http;
RefCount< AsyncCallT< Dialer > > asyncCall(int aDebugSection, int aDebugLevel, const char *aName, const Dialer &aDialer)
#define JobCallback(dbgSection, dbgLevel, Dialer, job, method)
Convenience macro to create a Dialer-based job callback.
static char server[MAXLINE]
#define CBDATA_NAMESPACED_CLASS_INIT(namespace, type)
Acl::Answer const & fastCheck()
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
void syncAle(HttpRequest *adaptedRequest, const char *logUri) const override
assigns uninitialized adapted_request and url ALE components
SBuf & authority(bool requirePort=false) const
HttpRequest *const request
void initRequest(HttpRequest *)
void setLogUriToRawUri(const char *, const HttpRequestMethod &)
StoreEntry * storeEntry() const
const AccessLogEntry::Pointer al
access.log entry
noteTakeServerConnectionControl() callback parameter
virtual int pipelinePrefetchMax() const
returning N allows a pipeline of 1+N requests (see pipeline_prefetch)
void start() override
called by AsyncStart; do not call directly
void noteBodyConsumerAborted(BodyPipe::Pointer) override=0
bundles HTTP 1xx reply and the "successfully forwarded" callback
void removeIrrelevantContentLength()
Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2).
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
bool parseHeader(Http1::Parser &hp)
bool forcedBodyContinuation
whether we have responded with HTTP 100 or FTP 150 already
NotePairs::Pointer notes()
AnyP::Uri url
the request URI
Manages a connection from an HTTP/1 or HTTP/0.9 client.
void handleReply(HttpReply *rep, StoreIOBuffer receivedData) override
Server(const MasterXaction::Pointer &xact, const bool beHttpsServer)
void proceedAfterBodyContinuation(Http::StreamPointer context)
bool buildHttpRequest(Http::StreamPointer &context)
void setReplyError(Http::StreamPointer &context, HttpRequest::Pointer &request, err_type requestError, Http::StatusCode errStatusCode, const char *requestErrorBytes)
void noteTakeServerConnectionControl(ServerConnectionContext) override
void processParsedRequest(Http::StreamPointer &context) override
start processing a freshly parsed request
time_t idleTimeout() const override
timeout to use when waiting for the next request
bool writeControlMsgAndCall(HttpReply *rep, AsyncCall::Pointer &call) override
handle a control message received by context from a peer and call back
void start() override
called by AsyncStart; do not call directly
Http::Stream * parseOneRequest() override
void noteBodyConsumerAborted(BodyPipe::Pointer) override
void noteMoreBodySpaceAvailable(BodyPipe::Pointer) override
int pipelinePrefetchMax() const override
returning N allows a pipeline of 1+N requests (see pipeline_prefetch)
void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason=nullptr)
Http::StatusCode status() const
retrieve the status code for this status line
static Pointer MakePortful(const AnyP::PortCfgPointer &aPort)
void append(const NotePairs *src)
Append the entries of the src NotePairs list to our list.
time_t request_start_timeout
struct SquidConfig::@77 Timeout
struct SquidConfig::@91 accessList
acl_access * forceRequestBodyContinuation
char const * termedBuf() const
int caseCmp(char const *) const
void setReplyToError(err_type, Http::StatusCode, char const *, const ConnStateData *, HttpRequest *, const char *, Auth::UserRequest::Pointer)
builds error using clientBuildError() and calls setReplyToError() below
void clientProcessRequestFinished(ConnStateData *conn, const HttpRequest::Pointer &request)
void clientProcessRequest(ConnStateData *conn, const Http1::RequestParserPointer &hp, Http::Stream *context)
void commSetConnTimeout(const Comm::ConnectionPointer &conn, time_t timeout, AsyncCall::Pointer &callback)
bool isOpen(const int fd)
#define debugs(SECTION, LEVEL, CONTENT)
#define EBIT_TEST(flag, bit)
void Write(const Comm::ConnectionPointer &conn, const char *buf, int size, AsyncCall::Pointer &callback, FREE *free_func)
common part of ParseBws() and ParseStrctBws()
@ scHttpVersionNotSupported
@ scRequestHeaderFieldsTooLarge
ConnStateData * NewServer(const MasterXactionPointer &xact)
create a new HTTP connection handler; never returns NULL
AnyP::ProtocolVersion ProtocolVersion()
ConnStateData * NewServer(const MasterXactionPointer &xact)
create a new HTTPS connection handler; never returns NULL
void switchToTunnel(HttpRequest *request, const Comm::ConnectionPointer &clientConn, const Comm::ConnectionPointer &srvConn, const SBuf &preReadServerData)