#include <HttpTunneler.h>


Classes | |
class | CbDialer |
Callback dialer API to allow Tunneler to set the answer. More... | |
Public Types | |
typedef CbcPointer< AsyncJob > | Pointer |
Public Member Functions | |
Tunneler (const Comm::ConnectionPointer &conn, const HttpRequestPointer &req, AsyncCall::Pointer &aCallback, time_t timeout, const AccessLogEntryPointer &alp) | |
Tunneler (const Tunneler &)=delete | |
Tunneler & | operator= (const Tunneler &)=delete |
void | setDelayId (DelayId delay_id) |
bool | canBeCalled (AsyncCall &call) const |
whether we can be called More... | |
void | callStart (AsyncCall &call) |
virtual void | callEnd () |
called right after the called job method More... | |
virtual void | callException (const std::exception &e) |
called when the job throws during an async call More... | |
void | handleStopRequest () |
process external request to terminate now (i.e. during this async call) More... | |
virtual void * | toCbdata ()=0 |
Static Public Member Functions | |
static void | Start (const Pointer &job) |
Public Attributes | |
bool | noteFwdPconnUse |
hack: whether the connection requires fwdPconnPool->noteUses() More... | |
const InstanceId< AsyncJob > | id |
job identifier More... | |
Protected Member Functions | |
virtual | ~Tunneler () |
virtual void | start () |
called by AsyncStart; do not call directly More... | |
virtual bool | doneAll () const |
whether positive goal has been reached More... | |
virtual void | swanSong () |
virtual const char * | status () const |
internal cleanup; do not call directly More... | |
void | handleConnectionClosure (const CommCloseCbParams &) |
void | watchForClosures () |
make sure we quit if/when the connection is gone More... | |
void | handleTimeout (const CommTimeoutCbParams &) |
The connection read timeout callback handler. More... | |
void | startReadingResponse () |
void | writeRequest () |
void | handleWrittenRequest (const CommIoCbParams &) |
Called when we are done writing a CONNECT request header to a peer. More... | |
void | handleReadyRead (const CommIoCbParams &) |
Called when we read [a part of] CONNECT response from the peer. More... | |
void | readMore () |
void | handleResponse (const bool eof) |
Parses [possibly incomplete] CONNECT response and reacts to it. More... | |
void | bailOnResponseError (const char *error, HttpReply *) |
void | deleteThis (const char *aReason) |
void | mustStop (const char *aReason) |
bool | done () const |
the job is destroyed in callEnd() when done() More... | |
Protected Attributes | |
const char * | stopReason |
reason for forcing done() to be true More... | |
const char * | typeName |
kid (leaf) class name, for debugging More... | |
AsyncCall::Pointer | inCall |
the asynchronous call being handled, if any More... | |
bool | started_ = false |
Start() has finished successfully. More... | |
bool | swanSang_ = false |
swanSong() was called More... | |
Private Member Functions | |
CBDATA_CLASS (Tunneler) | |
void | bailWith (ErrorState *) |
sends the given error to the initiator More... | |
void | sendSuccess () |
sends the ready-to-use tunnel to the initiator More... | |
void | callBack () |
a bailWith(), sendSuccess() helper: sends results to the initiator More... | |
void | disconnect () |
stops monitoring the connection More... | |
void | countFailingConnection () |
updates connection usage history before the connection is closed More... | |
TunnelerAnswer & | answer () |
convenience method to get to the answer fields More... | |
Private Attributes | |
AsyncCall::Pointer | writer |
called when the request has been written More... | |
AsyncCall::Pointer | reader |
called when the response should be read More... | |
AsyncCall::Pointer | closer |
called when the connection is being closed More... | |
Comm::ConnectionPointer | connection |
TCP connection to the cache_peer. More... | |
HttpRequestPointer | request |
peer connection trigger or cause More... | |
AsyncCall::Pointer | callback |
we call this with the results More... | |
SBuf | url |
request-target for the CONNECT request More... | |
time_t | lifetimeLimit |
do not run longer than this More... | |
AccessLogEntryPointer | al |
info for the future access.log entry More... | |
DelayId | delayId |
SBuf | readBuf |
Http1::ResponseParserPointer | hp |
Parser being used at present to parse the HTTP peer response. More... | |
const time_t | startTime |
when the tunnel establishment started More... | |
bool | requestWritten |
whether we successfully wrote the request More... | |
bool | tunnelEstablished |
whether we got a 200 OK response More... | |
Detailed Description
Negotiates an HTTP CONNECT tunnel through a forward proxy using a given (open and, if needed, encrypted) TCP connection to that proxy. Owns the connection during these negotiations. The caller receives TunnelerAnswer.
Definition at line 32 of file HttpTunneler.h.
Member Typedef Documentation
◆ Pointer
|
inherited |
Definition at line 34 of file AsyncJob.h.
Constructor & Destructor Documentation
◆ Tunneler() [1/2]
Http::Tunneler::Tunneler | ( | const Comm::ConnectionPointer & | conn, |
const HttpRequestPointer & | req, | ||
AsyncCall::Pointer & | aCallback, | ||
time_t | timeout, | ||
const AccessLogEntryPointer & | alp | ||
) |
Definition at line 29 of file HttpTunneler.cc.
References assert, AnyP::Uri::authority(), callback, connection, debugs, AsyncCall::getDialer(), request, url, HttpRequest::url, and watchForClosures().
◆ Tunneler() [2/2]
|
delete |
◆ ~Tunneler()
|
protectedvirtual |
Definition at line 51 of file HttpTunneler.cc.
References debugs.
Member Function Documentation
◆ answer()
|
private |
Definition at line 64 of file HttpTunneler.cc.
References Must.
◆ bailOnResponseError()
|
protected |
Definition at line 349 of file HttpTunneler.cc.
References debugs, ERR_CONNECT_FAIL, error(), request(), and Http::scBadGateway.
◆ bailWith()
|
private |
Definition at line 364 of file HttpTunneler.cc.
◆ callBack()
|
private |
Definition at line 423 of file HttpTunneler.cc.
References assert, conn, debugs, and ScheduleCallHere.
◆ callEnd()
|
virtualinherited |
called right after the called job method
Reimplemented in Adaptation::Icap::Xaction.
Definition at line 137 of file AsyncJob.cc.
References assert, AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::done(), AsyncJob::inCall, NULL, AsyncJob::started_, AsyncJob::status(), AsyncJob::swanSang_, AsyncJob::swanSong(), and AsyncJob::typeName.
Referenced by Adaptation::Icap::Xaction::callEnd(), and AsyncJob::deleteThis().
◆ callException()
|
virtualinherited |
Reimplemented in Ftp::Server, Ipc::Inquirer, Ipc::Forwarder, Adaptation::Icap::Xaction, Adaptation::Icap::ServiceRep, Adaptation::Icap::ModXact, ClientHttpRequest, and ConnStateData.
Definition at line 128 of file AsyncJob.cc.
References cbdataReferenceValid(), debugs, Must, AsyncJob::mustStop(), and CbdataParent::toCbdata().
Referenced by ConnStateData::callException(), Adaptation::Icap::Xaction::callException(), Ipc::Forwarder::callException(), Ipc::Inquirer::callException(), and Ftp::Server::callException().
◆ callStart()
|
inherited |
called just before the called method
Definition at line 115 of file AsyncJob.cc.
References cbdataReferenceValid(), AsyncCall::debugLevel, debugs, AsyncCall::debugSection, AsyncJob::inCall, Must, AsyncJob::status(), CbdataParent::toCbdata(), and AsyncJob::typeName.
◆ canBeCalled()
|
inherited |
Definition at line 102 of file AsyncJob.cc.
References AsyncCall::cancel(), debugs, AsyncJob::inCall, and NULL.
◆ CBDATA_CLASS()
|
private |
◆ countFailingConnection()
|
private |
Definition at line 390 of file HttpTunneler.cc.
References assert, fd_table, fwdPconnPool, PconnPool::noteUses(), and peerConnectFailed().
◆ deleteThis()
|
protectedinherited |
Definition at line 50 of file AsyncJob.cc.
References asyncCall(), AsyncJob::callEnd(), debugs, AsyncJob::inCall, JobMemFun(), Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by ConnStateData::connStateClosed().
◆ disconnect()
|
private |
Definition at line 400 of file HttpTunneler.cc.
References comm_remove_close_handler(), commUnsetConnTimeout(), Comm::IsConnOpen(), and Comm::ReadCancel().
◆ done()
|
protectedinherited |
Definition at line 91 of file AsyncJob.cc.
References AsyncJob::doneAll(), NULL, and AsyncJob::stopReason.
Referenced by AsyncJob::callEnd(), HappyConnOpener::checkForNewConnection(), Downloader::downloadFinished(), and HappyConnOpener::maybeOpenPrimeConnection().
◆ doneAll()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 57 of file HttpTunneler.cc.
◆ handleConnectionClosure()
|
protected |
Definition at line 102 of file HttpTunneler.cc.
References ERR_CONNECT_FAIL, request(), and Http::scBadGateway.
Referenced by watchForClosures().
◆ handleReadyRead()
|
protected |
Definition at line 214 of file HttpTunneler.cc.
References StatCounters::all, assert, CommCommonCbParams::conn, Comm::ENDFILE, Comm::ERR_CLOSING, ERR_READ_ERROR, error(), CommCommonCbParams::flag, Comm::INPROGRESS, Must, Comm::OK, StatCounters::other, Comm::ReadNow(), request(), Http::scBadGateway, StatCounters::server, CommIoCbParams::size, statCounter, and CommCommonCbParams::xerrno.
Referenced by readMore().
◆ handleResponse()
|
protected |
Definition at line 287 of file HttpTunneler.cc.
References debugs, Raw::gap(), RefCount< C >::getRaw(), Http::Message::hdr_sz, Raw::minLevel(), Http::One::ResponseParser::parse(), HttpReply::parseHeader(), request(), Http::scOkay, Http::StatusLine::set(), HttpReply::sline, Http::Message::sources, Http::Message::srcHttp, and Http::StatusLine::status().
◆ handleStopRequest()
|
inlineinherited |
Definition at line 71 of file AsyncJob.h.
References AsyncJob::mustStop().
◆ handleTimeout()
|
protected |
Definition at line 130 of file HttpTunneler.cc.
References ERR_CONNECT_FAIL, request(), and Http::scGatewayTimeout.
Referenced by readMore().
◆ handleWrittenRequest()
|
protected |
Definition at line 189 of file HttpTunneler.cc.
References StatCounters::all, debugs, Comm::ERR_CLOSING, ERR_WRITE_ERROR, error(), CommCommonCbParams::flag, Must, Comm::OK, StatCounters::other, request(), Http::scBadGateway, StatCounters::server, CommIoCbParams::size, statCounter, and CommCommonCbParams::xerrno.
Referenced by writeRequest().
◆ mustStop()
|
protectedinherited |
Definition at line 70 of file AsyncJob.cc.
References debugs, AsyncJob::inCall, Must, NULL, AsyncJob::stopReason, and AsyncJob::typeName.
Referenced by HttpStateData::abortAll(), AsyncJob::callException(), HttpStateData::continueAfterParsingHeader(), HttpStateData::drop1xx(), HttpStateData::handleMoreRequestBodyAvailable(), AsyncJob::handleStopRequest(), HttpStateData::httpStateConnClosed(), HttpStateData::httpTimeout(), HttpStateData::proceedAfter1xx(), ConnStateData::proxyProtocolError(), HttpStateData::readReply(), HttpStateData::start(), and HttpStateData::wroteLast().
◆ operator=()
◆ readMore()
|
protected |
Definition at line 267 of file HttpTunneler.cc.
References commSetConnTimeout(), fd_table, handleReadyRead(), handleTimeout(), Comm::IsConnOpen(), JobCallback, Comm::MortalReadTimeout(), Must, Store::nil, and Comm::Read().
◆ sendSuccess()
|
private |
Definition at line 380 of file HttpTunneler.cc.
References assert, and Comm::IsConnOpen().
◆ setDelayId()
|
inline |
Definition at line 65 of file HttpTunneler.h.
References delayId.
◆ start()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 73 of file HttpTunneler.cc.
References assert, ERR_CONNECT_FAIL, fd_table, Comm::IsConnOpen(), Must, request(), Http::scBadGateway, Http::scInternalServerError, and AsyncJob::start().
◆ Start()
|
staticinherited |
Promises to start the configured job (eventually). The job is deemed to be running asynchronously beyond this point, so the caller should only access the job object via AsyncCalls rather than directly.
swanSong() is only called for jobs for which this method has returned successfully (i.e. without throwing).
Definition at line 24 of file AsyncJob.cc.
References CallJobHere, AsyncJob::start(), and AsyncJob::started_.
Referenced by Ftp::Server::AcceptCtrlConnection(), clientListenerConnectionOpened(), Ipc::Coordinator::handleCacheMgrRequest(), Ipc::Coordinator::handleSnmpRequest(), httpAccept(), httpsAccept(), httpStart(), idnsInitVC(), Ftp::Gateway::listenForDataChannel(), Ftp::Server::listenForDataConnection(), Log::TcpLogger::Open(), peerProbeConnect(), Mgr::FunAction::respond(), Mgr::InfoAction::respond(), Ipc::SendMessage(), Mgr::Inquirer::sendResponse(), snmpConstructReponse(), SquidMain(), CacheManager::start(), Adaptation::AccessCheck::Start(), Rock::Rebuild::Start(), JobWaitBase::start_(), BodyPipe::startAutoConsumptionIfNeeded(), Ftp::StartGateway(), Ftp::StartRelay(), PeerPoolMgrsRr::syncConfig(), and Rock::SwapDir::updateHeaders().
◆ startReadingResponse()
|
protected |
Definition at line 136 of file HttpTunneler.cc.
References debugs.
◆ status()
|
protectedvirtual |
for debugging, starts with space
Reimplemented from AsyncJob.
Definition at line 449 of file HttpTunneler.cc.
References MemBuf::append(), Packable::appendf(), MemBuf::content(), MemBuf::reset(), and MemBuf::terminate().
◆ swanSong()
|
protectedvirtual |
Reimplemented from AsyncJob.
Definition at line 433 of file HttpTunneler.cc.
References assert, ERR_GATEWAY_FAILURE, Comm::IsConnOpen(), request(), Http::scInternalServerError, and AsyncJob::swanSong().
◆ toCbdata()
|
pure virtualinherited |
Implemented in HttpStateData, ClientHttpRequest, and BodySink.
Referenced by AsyncJob::callException(), and AsyncJob::callStart().
◆ watchForClosures()
|
protected |
Definition at line 115 of file HttpTunneler.cc.
References comm_add_close_handler(), debugs, fd_table, handleConnectionClosure(), Comm::IsConnOpen(), JobCallback, and Must.
Referenced by Tunneler().
◆ writeRequest()
|
protected |
Definition at line 145 of file HttpTunneler.cc.
References MemBuf::append(), Packable::appendf(), MemBuf::buf, HttpHeader::clean(), debugs, fd_note(), handleWrittenRequest(), hoRequest, HttpStateData::httpBuildRequestHeader(), MemBuf::init(), JobCallback, HttpHeader::packInto(), Http::StateFlags::peering, request(), and Comm::Write().
Member Data Documentation
◆ al
|
private |
Definition at line 117 of file HttpTunneler.h.
◆ callback
|
private |
Definition at line 114 of file HttpTunneler.h.
Referenced by Tunneler().
◆ closer
|
private |
Definition at line 110 of file HttpTunneler.h.
◆ connection
|
private |
Definition at line 112 of file HttpTunneler.h.
Referenced by Tunneler().
◆ delayId
|
private |
Definition at line 119 of file HttpTunneler.h.
Referenced by setDelayId().
◆ hp
|
private |
Definition at line 124 of file HttpTunneler.h.
◆ id
|
inherited |
Definition at line 73 of file AsyncJob.h.
◆ inCall
|
protectedinherited |
Definition at line 81 of file AsyncJob.h.
Referenced by AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::canBeCalled(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
◆ lifetimeLimit
|
private |
Definition at line 116 of file HttpTunneler.h.
◆ noteFwdPconnUse
bool Http::Tunneler::noteFwdPconnUse |
Definition at line 69 of file HttpTunneler.h.
◆ readBuf
|
private |
either unparsed response or post-response bytes
Definition at line 122 of file HttpTunneler.h.
◆ reader
|
private |
Definition at line 109 of file HttpTunneler.h.
◆ request
|
private |
Definition at line 113 of file HttpTunneler.h.
Referenced by Tunneler().
◆ requestWritten
|
private |
Definition at line 128 of file HttpTunneler.h.
◆ started_
|
protectedinherited |
Definition at line 83 of file AsyncJob.h.
Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().
◆ startTime
|
private |
Definition at line 126 of file HttpTunneler.h.
◆ stopReason
|
protectedinherited |
Definition at line 79 of file AsyncJob.h.
Referenced by AsyncJob::deleteThis(), AsyncJob::done(), AsyncJob::mustStop(), AsyncJob::status(), and HappyConnOpener::status().
◆ swanSang_
|
protectedinherited |
Definition at line 84 of file AsyncJob.h.
Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().
◆ tunnelEstablished
|
private |
Definition at line 129 of file HttpTunneler.h.
◆ typeName
|
protectedinherited |
Definition at line 80 of file AsyncJob.h.
Referenced by AsyncJob::AsyncJob(), Adaptation::Icap::Xaction::Xaction(), AsyncJob::~AsyncJob(), AsyncJob::callEnd(), AsyncJob::callStart(), AsyncJob::deleteThis(), and AsyncJob::mustStop().
◆ url
|
private |
Definition at line 115 of file HttpTunneler.h.
Referenced by Tunneler().
◆ writer
|
private |
Definition at line 108 of file HttpTunneler.h.
The documentation for this class was generated from the following files:
- src/clients/HttpTunneler.h
- src/clients/HttpTunneler.cc