#include <HttpTunneler.h>

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

Classes

class  CbDialer
 Callback dialer API to allow Tunneler to set the answer. More...
 

Public Types

typedef CbcPointer< AsyncJobPointer
 

Public Member Functions

 Tunneler (const Comm::ConnectionPointer &conn, const HttpRequestPointer &req, AsyncCall::Pointer &aCallback, time_t timeout, const AccessLogEntryPointer &alp)
 
 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)
 

Public Attributes

bool noteFwdPconnUse
 hack: whether the connection requires fwdPconnPool->noteUses() More...
 
const InstanceId< AsyncJobid
 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...
 
TunnelerAnsweranswer ()
 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

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 
)

◆ Tunneler() [2/2]

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

◆ ~Tunneler()

Http::Tunneler::~Tunneler ( )
protectedvirtual

Definition at line 50 of file HttpTunneler.cc.

References debugs.

Member Function Documentation

◆ answer()

Http::TunnelerAnswer & Http::Tunneler::answer ( )
private

Definition at line 63 of file HttpTunneler.cc.

References Must.

◆ bailOnResponseError()

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

Definition at line 348 of file HttpTunneler.cc.

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

◆ bailWith()

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

Definition at line 363 of file HttpTunneler.cc.

References error(), and Must.

◆ callBack()

void Http::Tunneler::callBack ( )
private

Definition at line 422 of file HttpTunneler.cc.

References assert, conn, 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 102 of file AsyncJob.cc.

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

◆ CBDATA_CLASS()

Http::Tunneler::CBDATA_CLASS ( Tunneler  )
private

◆ countFailingConnection()

void Http::Tunneler::countFailingConnection ( )
private

Definition at line 389 of file HttpTunneler.cc.

References assert, fd_table, fwdPconnPool, PconnPool::noteUses(), and peerConnectFailed().

◆ 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
protectedvirtual

Reimplemented from AsyncJob.

Definition at line 56 of file HttpTunneler.cc.

◆ handleConnectionClosure()

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

Definition at line 101 of file HttpTunneler.cc.

References ERR_CONNECT_FAIL, request(), and Http::scBadGateway.

Referenced by watchForClosures().

◆ handleReadyRead()

◆ handleResponse()

◆ handleStopRequest()

void AsyncJob::handleStopRequest ( )
inlineinherited

Definition at line 71 of file AsyncJob.h.

References AsyncJob::mustStop().

◆ handleTimeout()

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

Definition at line 129 of file HttpTunneler.cc.

References ERR_CONNECT_FAIL, request(), and Http::scGatewayTimeout.

Referenced by readMore().

◆ handleWrittenRequest()

◆ mustStop()

◆ operator=()

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

◆ readMore()

void Http::Tunneler::readMore ( )
protected

◆ sendSuccess()

void Http::Tunneler::sendSuccess ( )
private

Definition at line 379 of file HttpTunneler.cc.

References assert, and Comm::IsConnOpen().

◆ setDelayId()

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

Definition at line 65 of file HttpTunneler.h.

References delayId.

◆ start()

void Http::Tunneler::start ( )
protectedvirtual

◆ Start()

◆ startReadingResponse()

void Http::Tunneler::startReadingResponse ( )
protected

Definition at line 135 of file HttpTunneler.cc.

References debugs.

◆ status()

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

for debugging, starts with space

Reimplemented from AsyncJob.

Definition at line 448 of file HttpTunneler.cc.

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

◆ swanSong()

void Http::Tunneler::swanSong ( )
protectedvirtual

◆ 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 117 of file HttpTunneler.h.

◆ callback

AsyncCall::Pointer Http::Tunneler::callback
private

Definition at line 114 of file HttpTunneler.h.

Referenced by Tunneler().

◆ closer

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

Definition at line 110 of file HttpTunneler.h.

◆ connection

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

Definition at line 112 of file HttpTunneler.h.

Referenced by Tunneler().

◆ delayId

DelayId Http::Tunneler::delayId
private

Definition at line 119 of file HttpTunneler.h.

Referenced by setDelayId().

◆ hp

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

Definition at line 124 of file HttpTunneler.h.

◆ id

const InstanceId<AsyncJob> AsyncJob::id
inherited

Definition at line 73 of file AsyncJob.h.

◆ inCall

AsyncCall::Pointer AsyncJob::inCall
protectedinherited

◆ lifetimeLimit

time_t Http::Tunneler::lifetimeLimit
private

Definition at line 116 of file HttpTunneler.h.

◆ noteFwdPconnUse

bool Http::Tunneler::noteFwdPconnUse

Definition at line 69 of file HttpTunneler.h.

◆ readBuf

SBuf Http::Tunneler::readBuf
private

either unparsed response or post-response bytes

Definition at line 122 of file HttpTunneler.h.

◆ reader

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

Definition at line 109 of file HttpTunneler.h.

◆ request

HttpRequestPointer Http::Tunneler::request
private

Definition at line 113 of file HttpTunneler.h.

Referenced by Tunneler().

◆ requestWritten

bool Http::Tunneler::requestWritten
private

Definition at line 128 of file HttpTunneler.h.

◆ started_

bool AsyncJob::started_ = false
protectedinherited

Definition at line 83 of file AsyncJob.h.

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

◆ startTime

const time_t Http::Tunneler::startTime
private

Definition at line 126 of file HttpTunneler.h.

◆ stopReason

const char* AsyncJob::stopReason
protectedinherited

◆ swanSang_

bool AsyncJob::swanSang_ = false
protectedinherited

Definition at line 84 of file AsyncJob.h.

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

◆ tunnelEstablished

bool Http::Tunneler::tunnelEstablished
private

Definition at line 129 of file HttpTunneler.h.

◆ typeName

◆ url

SBuf Http::Tunneler::url
private

Definition at line 115 of file HttpTunneler.h.

Referenced by Tunneler().

◆ writer

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

Definition at line 108 of file HttpTunneler.h.


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors