Squid Web Cache master
Loading...
Searching...
No Matches
HttpTunneler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2025 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_HTTPTUNNELER_H
10#define SQUID_SRC_CLIENTS_HTTPTUNNELER_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_HTTPTUNNELER_H */
112
RefCount< AccessLogEntry > AccessLogEntryPointer
void error(char *format,...)
a smart AsyncCall pointer for delivery of future results
bool doneAll() const override
whether positive goal has been reached
void countFailingConnection()
updates connection usage history before the connection is closed
void disconnect()
stops monitoring the connection
void bailOnResponseError(const char *error, HttpReply *)
CBDATA_CHILD(Tunneler)
const time_t startTime
when the tunnel establishment started
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
void handleConnectionClosure(const CommCloseCbParams &)
void start() override
called by AsyncStart; do not call directly
AsyncCall::Pointer closer
called when the connection is being closed
~Tunneler() override
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
void watchForClosures()
make sure we quit if/when the connection is gone
void setDelayId(DelayId delay_id)
AsyncCallback< Answer > callback
answer destination
AsyncCall::Pointer reader
called when the response should be read
bool requestWritten
whether we successfully wrote the request
void sendSuccess()
sends the ready-to-use tunnel to the initiator
AsyncCall::Pointer writer
called when the request has been written
AccessLogEntryPointer al
info for the future access.log entry
void startReadingResponse()
bool noteFwdPconnUse
hack: whether the connection requires fwdPconnPool->noteUses()
SBuf url
request-target for the CONNECT request
HttpRequestPointer request
peer connection trigger or cause
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.
Comm::ConnectionPointer connection
TCP connection to the cache_peer.
Definition SBuf.h:94
Definition forward.h:18