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_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 
22 class ErrorState;
25 
26 namespace Http
27 {
28 
32 class Tunneler: virtual public AsyncJob
33 {
35 
36 public:
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 
50 protected:
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();
60  void handleTimeout(const CommTimeoutCbParams &);
61  void startReadingResponse();
62  void writeRequest();
64  void handleReadyRead(const CommIoCbParams&);
65  void readMore();
66  void handleResponse(const bool eof);
67  void bailOnResponseError(const char *error, HttpReply *);
68 
69 private:
71  void bailWith(ErrorState*);
72 
74  void sendSuccess();
75 
77  void callBack();
78 
80  void disconnect();
81 
84 
88 
93  time_t lifetimeLimit;
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 
void startReadingResponse()
AsyncCall::Pointer reader
called when the response should be read
Definition: HttpTunneler.h:86
void sendSuccess()
sends the ready-to-use tunnel to the initiator
Comm::ConnectionPointer connection
TCP connection to the cache_peer.
Definition: HttpTunneler.h:89
time_t lifetimeLimit
do not run longer than this
Definition: HttpTunneler.h:93
void disconnect()
stops monitoring the connection
void bailWith(ErrorState *)
sends the given error to the initiator
void handleTimeout(const CommTimeoutCbParams &)
The connection read timeout callback handler.
void error(char *format,...)
Definition: SBuf.h:93
a smart AsyncCall pointer for delivery of future results
void countFailingConnection()
updates connection usage history before the connection is closed
Definition: forward.h:17
bool requestWritten
whether we successfully wrote the request
Definition: HttpTunneler.h:105
const char * status() const override
internal cleanup; do not call directly
void bailOnResponseError(const char *error, HttpReply *)
const time_t startTime
when the tunnel establishment started
Definition: HttpTunneler.h:103
void handleReadyRead(const CommIoCbParams &)
Called when we read [a part of] CONNECT response from the peer.
AsyncCall::Pointer closer
called when the connection is being closed
Definition: HttpTunneler.h:87
void start() override
called by AsyncStart; do not call directly
Definition: HttpTunneler.cc:60
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: HttpTunneler.h:23
DelayId delayId
Definition: HttpTunneler.h:96
void handleResponse(const bool eof)
Parses [possibly incomplete] CONNECT response and reacts to it.
Tunneler(const Comm::ConnectionPointer &, const HttpRequestPointer &, const AsyncCallback< Answer > &, time_t timeout, const AccessLogEntryPointer &)
Definition: HttpTunneler.cc:29
bool tunnelEstablished
whether we got a 200 OK response
Definition: HttpTunneler.h:106
AccessLogEntryPointer al
info for the future access.log entry
Definition: HttpTunneler.h:94
void handleConnectionClosure(const CommCloseCbParams &)
Definition: HttpTunneler.cc:89
AsyncCallback< Answer > callback
answer destination
Definition: HttpTunneler.h:91
HttpRequestPointer request
peer connection trigger or cause
Definition: HttpTunneler.h:90
void callBack()
a bailWith(), sendSuccess() helper: sends results to the initiator
bool doneAll() const override
whether positive goal has been reached
Definition: HttpTunneler.cc:54
SBuf url
request-target for the CONNECT request
Definition: HttpTunneler.h:92
CBDATA_CHILD(Tunneler)
void handleWrittenRequest(const CommIoCbParams &)
Called when we are done writing a CONNECT request header to a peer.
void setDelayId(DelayId delay_id)
Definition: HttpTunneler.h:44
~Tunneler() override
Definition: HttpTunneler.cc:48
void swanSong() override
AsyncCall::Pointer writer
called when the request has been written
Definition: HttpTunneler.h:85
Tunneler & operator=(const Tunneler &)=delete
bool noteFwdPconnUse
hack: whether the connection requires fwdPconnPool->noteUses()
Definition: HttpTunneler.h:48
Http1::ResponseParserPointer hp
Parser being used at present to parse the HTTP peer response.
Definition: HttpTunneler.h:101
void watchForClosures()
make sure we quit if/when the connection is gone

 

Introduction

Documentation

Support

Miscellaneous