HttpTunneler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_SRC_CLIENTS_HTTP_TUNNELER_H
10#define SQUID_SRC_CLIENTS_HTTP_TUNNELER_H
11
12#include "base/AsyncCallbacks.h"
13#include "base/AsyncJob.h"
14#include "clients/forward.h"
16#include "CommCalls.h"
17#if USE_DELAY_POOLS
18#include "DelayId.h"
19#endif
20#include "http/forward.h"
21
22class ErrorState;
23class AccessLogEntry;
25
26namespace Http
27{
28
32class Tunneler: virtual public AsyncJob
33{
35
36public:
38
39 Tunneler(const Comm::ConnectionPointer &, const HttpRequestPointer &, const AsyncCallback<Answer> &, time_t timeout, const AccessLogEntryPointer &);
40 Tunneler(const Tunneler &) = delete;
41 Tunneler &operator =(const Tunneler &) = delete;
42
43#if USE_DELAY_POOLS
44 void setDelayId(DelayId delay_id) {delayId = delay_id;}
45#endif
46
49
50protected:
51 /* AsyncJob API */
52 ~Tunneler() override;
53 void start() override;
54 bool doneAll() const override;
55 void swanSong() override;
56 const char *status() const override;
57
59 void watchForClosures();
62 void writeRequest();
65 void readMore();
66 void handleResponse(const bool eof);
67 void bailOnResponseError(const char *error, HttpReply *);
68
69private:
71 void bailWith(ErrorState*);
72
74 void sendSuccess();
75
77 void callBack();
78
80 void disconnect();
81
84
88
95#if USE_DELAY_POOLS
97#endif
98
102
103 const time_t startTime;
104
107};
108
109} // namespace Http
110
111#endif /* SQUID_SRC_CLIENTS_HTTP_TUNNELER_H */
112
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: HttpTunneler.h:24
void error(char *format,...)
a smart AsyncCall pointer for delivery of future results
bool doneAll() const override
whether positive goal has been reached
Definition: HttpTunneler.cc:54
void disconnect()
stops monitoring the connection
void bailOnResponseError(const char *error, HttpReply *)
CBDATA_CHILD(Tunneler)
const time_t startTime
when the tunnel establishment started
Definition: HttpTunneler.h:103
Tunneler(const Tunneler &)=delete
void handleResponse(const bool eof)
Parses [possibly incomplete] CONNECT response and reacts to it.
void swanSong() override
void callBack()
a bailWith(), sendSuccess() helper: sends results to the initiator
void bailWith(ErrorState *)
sends the given error to the initiator
const char * status() const override
internal cleanup; do not call directly
bool tunnelEstablished
whether we got a 200 OK response
Definition: HttpTunneler.h:106
void handleConnectionClosure(const CommCloseCbParams &)
Definition: HttpTunneler.cc:89
void start() override
called by AsyncStart; do not call directly
Definition: HttpTunneler.cc:60
AsyncCall::Pointer closer
called when the connection is being closed
Definition: HttpTunneler.h:87
~Tunneler() override
Definition: HttpTunneler.cc:48
void handleWrittenRequest(const CommIoCbParams &)
Called when we are done writing a CONNECT request header to a peer.
time_t lifetimeLimit
do not run longer than this
Definition: HttpTunneler.h:93
void watchForClosures()
make sure we quit if/when the connection is gone
void setDelayId(DelayId delay_id)
Definition: HttpTunneler.h:44
AsyncCallback< Answer > callback
answer destination
Definition: HttpTunneler.h:91
AsyncCall::Pointer reader
called when the response should be read
Definition: HttpTunneler.h:86
bool requestWritten
whether we successfully wrote the request
Definition: HttpTunneler.h:105
void sendSuccess()
sends the ready-to-use tunnel to the initiator
DelayId delayId
Definition: HttpTunneler.h:96
AsyncCall::Pointer writer
called when the request has been written
Definition: HttpTunneler.h:85
AccessLogEntryPointer al
info for the future access.log entry
Definition: HttpTunneler.h:94
void startReadingResponse()
Tunneler(const Comm::ConnectionPointer &, const HttpRequestPointer &, const AsyncCallback< Answer > &, time_t timeout, const AccessLogEntryPointer &)
Definition: HttpTunneler.cc:29
bool noteFwdPconnUse
hack: whether the connection requires fwdPconnPool->noteUses()
Definition: HttpTunneler.h:48
SBuf url
request-target for the CONNECT request
Definition: HttpTunneler.h:92
HttpRequestPointer request
peer connection trigger or cause
Definition: HttpTunneler.h:90
void handleTimeout(const CommTimeoutCbParams &)
The connection read timeout callback handler.
Tunneler & operator=(const Tunneler &)=delete
void handleReadyRead(const CommIoCbParams &)
Called when we read [a part of] CONNECT response from the peer.
Http1::ResponseParserPointer hp
Parser being used at present to parse the HTTP peer response.
Definition: HttpTunneler.h:101
Comm::ConnectionPointer connection
TCP connection to the cache_peer.
Definition: HttpTunneler.h:89
void countFailingConnection(const ErrorState *)
updates connection usage history before the connection is closed
Definition: SBuf.h:94
Definition: forward.h:18

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors