#include <HttpTunneler.h>

Inheritance diagram for Http::Tunneler:
Collaboration diagram for Http::Tunneler:

Public Types

using Answer = TunnelerAnswer
 
typedef CbcPointer< AsyncJobPointer
 

Public Member Functions

 Tunneler (const Comm::ConnectionPointer &, const HttpRequestPointer &, const AsyncCallback< Answer > &, time_t timeout, const AccessLogEntryPointer &)
 
 Tunneler (const Tunneler &)=delete
 
Tunneleroperator= (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)
 
static void RegisterWithCacheManager ()
 

Public Attributes

bool noteFwdPconnUse
 hack: whether the connection requires fwdPconnPool->noteUses() More...
 
const InstanceId< AsyncJobid
 job identifier More...
 

Protected Member Functions

 ~Tunneler () override
 
void start () override
 called by AsyncStart; do not call directly More...
 
bool doneAll () const override
 whether positive goal has been reached More...
 
void swanSong () override
 
const char * status () const override
 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...
 

Static Protected Member Functions

static void ReportAllJobs (StoreEntry *)
 writes a cache manager report about all jobs existing in this worker 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_CHILD (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 (const ErrorState *)
 updates connection usage history before the connection is closed More...
 
virtual void finalizedInCbdataChild ()=0
 hack: ensure CBDATA_CHILD() after a toCbdata()-defining CBDATA_INTERMEDIATE() 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...
 
AsyncCallback< Answercallback
 answer destination 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

◆ Answer

Definition at line 37 of file HttpTunneler.h.

◆ Pointer

Definition at line 34 of file AsyncJob.h.

Constructor & Destructor Documentation

◆ Tunneler() [1/2]

Http::Tunneler::Tunneler ( const Comm::ConnectionPointer conn,
const HttpRequestPointer req,
const AsyncCallback< Answer > &  aCallback,
time_t  timeout,
const AccessLogEntryPointer alp 
)

◆ Tunneler() [2/2]

Http::Tunneler::Tunneler ( const Tunneler )
delete

◆ ~Tunneler()

Http::Tunneler::~Tunneler ( )
overrideprotected

Definition at line 48 of file HttpTunneler.cc.

References debugs.

Member Function Documentation

◆ bailOnResponseError()

void Http::Tunneler::bailOnResponseError ( const char *  error,
HttpReply errorReply 
)
protected

Definition at line 336 of file HttpTunneler.cc.

References debugs, ERR_CONNECT_FAIL, error(), and Http::scBadGateway.

◆ bailWith()

void Http::Tunneler::bailWith ( ErrorState error)
private

Definition at line 351 of file HttpTunneler.cc.

References error(), and Must.

◆ callBack()

void Http::Tunneler::callBack ( )
private

Definition at line 409 of file HttpTunneler.cc.

References assert, debugs, and ScheduleCallHere.

◆ callEnd()

void AsyncJob::callEnd ( )
virtualinherited

◆ callException()

◆ callStart()

void AsyncJob::callStart ( AsyncCall call)
inherited

◆ canBeCalled()

bool AsyncJob::canBeCalled ( AsyncCall call) const
inherited

Definition at line 117 of file AsyncJob.cc.

References AsyncCall::cancel(), debugs, and AsyncJob::inCall.

◆ CBDATA_CHILD()

Http::Tunneler::CBDATA_CHILD ( Tunneler  )
private

◆ countFailingConnection()

void Http::Tunneler::countFailingConnection ( const ErrorState error)
private

◆ deleteThis()

void AsyncJob::deleteThis ( const char *  aReason)
protectedinherited

◆ disconnect()

void Http::Tunneler::disconnect ( )
private

◆ done()

bool AsyncJob::done ( ) const
protectedinherited

◆ doneAll()

bool Http::Tunneler::doneAll ( ) const
overrideprotectedvirtual

Reimplemented from AsyncJob.

Definition at line 54 of file HttpTunneler.cc.

◆ finalizedInCbdataChild()

virtual void CbdataParent::finalizedInCbdataChild ( )
privatepure virtualinherited

◆ handleConnectionClosure()

void Http::Tunneler::handleConnectionClosure ( const CommCloseCbParams )
protected

Definition at line 89 of file HttpTunneler.cc.

References ERR_CONNECT_FAIL, and Http::scBadGateway.

Referenced by watchForClosures().

◆ handleReadyRead()

◆ handleResponse()

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )
inlineinherited

Definition at line 73 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ handleTimeout()

void Http::Tunneler::handleTimeout ( const CommTimeoutCbParams )
protected

Definition at line 117 of file HttpTunneler.cc.

References ERR_CONNECT_FAIL, and Http::scGatewayTimeout.

Referenced by readMore().

◆ handleWrittenRequest()

◆ mustStop()

◆ operator=()

Tunneler & Http::Tunneler::operator= ( const Tunneler )
delete

◆ readMore()

void Http::Tunneler::readMore ( )
protected

◆ RegisterWithCacheManager()

void AsyncJob::RegisterWithCacheManager ( )
staticinherited

Definition at line 215 of file AsyncJob.cc.

References Mgr::RegisterAction(), and AsyncJob::ReportAllJobs().

Referenced by mainInitialize().

◆ ReportAllJobs()

void AsyncJob::ReportAllJobs ( StoreEntry e)
staticprotectedinherited

Definition at line 198 of file AsyncJob.cc.

References AllJobs().

Referenced by AsyncJob::RegisterWithCacheManager().

◆ sendSuccess()

void Http::Tunneler::sendSuccess ( )
private

Definition at line 367 of file HttpTunneler.cc.

References assert, and Comm::IsConnOpen().

◆ setDelayId()

void Http::Tunneler::setDelayId ( DelayId  delay_id)
inline

Definition at line 44 of file HttpTunneler.h.

References delayId.

◆ start()

void Http::Tunneler::start ( )
overrideprotectedvirtual

◆ Start()

◆ startReadingResponse()

void Http::Tunneler::startReadingResponse ( )
protected

Definition at line 123 of file HttpTunneler.cc.

References debugs.

◆ status()

const char * Http::Tunneler::status ( ) const
overrideprotectedvirtual

for debugging, starts with space

Reimplemented from AsyncJob.

Definition at line 433 of file HttpTunneler.cc.

References MemBuf::append(), Packable::appendf(), MemBuf::content(), MemBuf::reset(), and MemBuf::terminate().

◆ swanSong()

void Http::Tunneler::swanSong ( )
overrideprotectedvirtual

◆ toCbdata()

virtual void * CbdataParent::toCbdata ( )
pure virtualinherited

◆ watchForClosures()

void Http::Tunneler::watchForClosures ( )
protected

◆ writeRequest()

Member Data Documentation

◆ al

AccessLogEntryPointer Http::Tunneler::al
private

Definition at line 94 of file HttpTunneler.h.

◆ callback

AsyncCallback<Answer> Http::Tunneler::callback
private

Definition at line 91 of file HttpTunneler.h.

◆ closer

AsyncCall::Pointer Http::Tunneler::closer
private

Definition at line 87 of file HttpTunneler.h.

◆ connection

Comm::ConnectionPointer Http::Tunneler::connection
private

Definition at line 89 of file HttpTunneler.h.

Referenced by Tunneler().

◆ delayId

DelayId Http::Tunneler::delayId
private

Definition at line 96 of file HttpTunneler.h.

Referenced by setDelayId().

◆ hp

Http1::ResponseParserPointer Http::Tunneler::hp
private

Definition at line 101 of file HttpTunneler.h.

◆ id

const InstanceId<AsyncJob> AsyncJob::id
inherited

Definition at line 75 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ lifetimeLimit

time_t Http::Tunneler::lifetimeLimit
private

Definition at line 93 of file HttpTunneler.h.

◆ noteFwdPconnUse

bool Http::Tunneler::noteFwdPconnUse

Definition at line 48 of file HttpTunneler.h.

◆ readBuf

SBuf Http::Tunneler::readBuf
private

either unparsed response or post-response bytes

Definition at line 99 of file HttpTunneler.h.

◆ reader

AsyncCall::Pointer Http::Tunneler::reader
private

Definition at line 86 of file HttpTunneler.h.

◆ request

HttpRequestPointer Http::Tunneler::request
private

Definition at line 90 of file HttpTunneler.h.

Referenced by Tunneler().

◆ requestWritten

bool Http::Tunneler::requestWritten
private

Definition at line 105 of file HttpTunneler.h.

◆ started_

bool AsyncJob::started_ = false
protectedinherited

Definition at line 88 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), AsyncJob::callEnd(), and AsyncJob::Start().

◆ startTime

const time_t Http::Tunneler::startTime
private

Definition at line 103 of file HttpTunneler.h.

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ swanSang_

bool AsyncJob::swanSang_ = false
protectedinherited

Definition at line 89 of file AsyncJob.h.

Referenced by AsyncJob::~AsyncJob(), and AsyncJob::callEnd().

◆ tunnelEstablished

bool Http::Tunneler::tunnelEstablished
private

Definition at line 106 of file HttpTunneler.h.

◆ typeName

◆ url

SBuf Http::Tunneler::url
private

Definition at line 92 of file HttpTunneler.h.

Referenced by Tunneler().

◆ writer

AsyncCall::Pointer Http::Tunneler::writer
private

Definition at line 85 of file HttpTunneler.h.


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors