]>
Commit | Line | Data |
---|---|---|
c8be6d7b | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
c8be6d7b | 3 | * |
bbc27441 AJ |
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. | |
c8be6d7b | 7 | */ |
8 | ||
9 | #ifndef SQUID_CLIENTSIDEREQUEST_H | |
10 | #define SQUID_CLIENTSIDEREQUEST_H | |
11 | ||
450e0c10 | 12 | #include "AccessLogEntry.h" |
602d9612 | 13 | #include "acl/forward.h" |
a2ac85d9 | 14 | #include "client_side.h" |
602d9612 | 15 | #include "clientStream.h" |
63df1d28 | 16 | #include "http/forward.h" |
43ca19e0 | 17 | #include "HttpHeaderRange.h" |
02c8dde5 | 18 | #include "LogTags.h" |
1a6cca01 | 19 | #include "Store.h" |
528b2c61 | 20 | |
a83c6ed6 AR |
21 | #if USE_ADAPTATION |
22 | #include "adaptation/forward.h" | |
23 | #include "adaptation/Initiator.h" | |
de31d06f | 24 | #endif |
25 | ||
c6983ec7 FC |
26 | class ClientRequestContext; |
27 | class ConnStateData; | |
90f396d5 | 28 | class MemObject; |
62e76326 | 29 | |
c6983ec7 | 30 | /* client_side_request.c - client side request related routines (pure logic) */ |
5ceaee75 | 31 | int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t, const MasterXactionPointer &); |
924f73bc | 32 | |
62e76326 | 33 | class ClientHttpRequest |
a83c6ed6 | 34 | #if USE_ADAPTATION |
f53969cc SM |
35 | : public Adaptation::Initiator, // to start adaptation transactions |
36 | public BodyConsumer // to receive reply bodies in request satisf. mode | |
5f8252d2 | 37 | #endif |
62e76326 | 38 | { |
5c2f68b7 | 39 | CBDATA_CLASS(ClientHttpRequest); |
62e76326 | 40 | |
528b2c61 | 41 | public: |
be364179 | 42 | ClientHttpRequest(ConnStateData *csd); |
528b2c61 | 43 | ~ClientHttpRequest(); |
44 | /* Not implemented - present to prevent synthetic operations */ | |
45 | ClientHttpRequest(ClientHttpRequest const &); | |
46 | ClientHttpRequest& operator=(ClientHttpRequest const &); | |
62e76326 | 47 | |
30abd221 | 48 | String rangeBoundaryStr() const; |
528b2c61 | 49 | void freeResources(); |
50 | void updateCounters(); | |
51 | void logRequest(); | |
1a6cca01 AJ |
52 | MemObject * memObject() const { |
53 | return (storeEntry() ? storeEntry()->mem_obj : nullptr); | |
54 | } | |
528b2c61 | 55 | bool multipartRangeRequest() const; |
8e2745f4 | 56 | void processRequest(); |
57 | void httpStart(); | |
0655fa4d | 58 | bool onlyIfCached()const; |
59 | bool gotEnough() const; | |
1a6cca01 | 60 | StoreEntry *storeEntry() const { return entry_; } |
86a2f789 | 61 | void storeEntry(StoreEntry *); |
1a6cca01 | 62 | StoreEntry *loggingEntry() const { return loggingEntry_; } |
0976f8db | 63 | void loggingEntry(StoreEntry *); |
0655fa4d | 64 | |
1a6cca01 AJ |
65 | ConnStateData * getConn() const { |
66 | return (cbdataReferenceValid(conn_) ? conn_ : nullptr); | |
67 | } | |
68 | void setConn(ConnStateData *aConn) { | |
69 | if (conn_ != aConn) { | |
70 | cbdataReferenceDone(conn_); | |
71 | conn_ = cbdataReference(aConn); | |
72 | } | |
73 | } | |
be364179 | 74 | |
be364179 AJ |
75 | /** Details of the client socket which produced us. |
76 | * Treat as read-only for the lifetime of this HTTP request. | |
77 | */ | |
78 | Comm::ConnectionPointer clientConnection; | |
79 | ||
f53969cc | 80 | HttpRequest *request; /* Parsed URL ... */ |
528b2c61 | 81 | char *uri; |
82 | char *log_uri; | |
a8a0b1c2 | 83 | String store_id; /* StoreID for transactions where the request member is nil */ |
62e76326 | 84 | |
cc8c4af2 AJ |
85 | struct Out { |
86 | Out() : offset(0), size(0), headers_sz(0) {} | |
87 | ||
47f6e231 | 88 | int64_t offset; |
ac9f46af | 89 | uint64_t size; |
62e76326 | 90 | size_t headers_sz; |
3d0ac046 | 91 | } out; |
62e76326 | 92 | |
f53969cc SM |
93 | HttpHdrRangeIter range_iter; /* data for iterating thru range specs */ |
94 | size_t req_sz; /* raw request size on input, not current request size */ | |
62e76326 | 95 | |
02c8dde5 AJ |
96 | /// the processing tags associated with this request transaction. |
97 | // NP: still an enum so each stage altering it must take care when replacing it. | |
98 | LogTags logType; | |
62e76326 | 99 | |
41ebd397 | 100 | AccessLogEntry::Pointer al; ///< access.log entry |
62e76326 | 101 | |
cc8c4af2 AJ |
102 | struct Flags { |
103 | Flags() : accel(false), internal(false), done_copying(false), purging(false) {} | |
104 | ||
be4d35dc | 105 | bool accel; |
be4d35dc FC |
106 | bool internal; |
107 | bool done_copying; | |
108 | bool purging; | |
3d0ac046 | 109 | } flags; |
62e76326 | 110 | |
cc8c4af2 AJ |
111 | struct Redirect { |
112 | Redirect() : status(Http::scNone), location(NULL) {} | |
113 | ||
955394ce | 114 | Http::StatusCode status; |
62e76326 | 115 | char *location; |
3d0ac046 | 116 | } redirect; |
62e76326 | 117 | |
528b2c61 | 118 | dlink_node active; |
119 | dlink_list client_stream; | |
120 | int mRangeCLen(); | |
62e76326 | 121 | |
de31d06f | 122 | ClientRequestContext *calloutContext; |
123 | void doCallouts(); | |
124 | ||
32fd6d8a CT |
125 | /// Build an error reply. For use with the callouts. |
126 | void calloutsError(const err_type error, const int errDetail); | |
127 | ||
a83c6ed6 AR |
128 | #if USE_ADAPTATION |
129 | // AsyncJob virtual methods | |
26ac0430 AJ |
130 | virtual bool doneAll() const { |
131 | return Initiator::doneAll() && | |
132 | BodyConsumer::doneAll() && false; | |
133 | } | |
9d52ba11 | 134 | virtual void callException(const std::exception &ex); |
1cf238db | 135 | #endif |
136 | ||
528b2c61 | 137 | private: |
47f6e231 | 138 | int64_t maxReplyBodySize_; |
86a2f789 | 139 | StoreEntry *entry_; |
0976f8db | 140 | StoreEntry *loggingEntry_; |
1cf238db | 141 | ConnStateData * conn_; |
de31d06f | 142 | |
cb4f4424 | 143 | #if USE_OPENSSL |
caf3666d | 144 | /// whether (and how) the request needs to be bumped |
08097970 | 145 | Ssl::BumpMode sslBumpNeed_; |
e0c0d54c | 146 | |
807ecef2 | 147 | public: |
08097970 AR |
148 | /// returns raw sslBump mode value |
149 | Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; } | |
150 | /// returns true if and only if the request needs to be bumped | |
5d65362c | 151 | bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst || sslBumpNeed_ == Ssl::bumpBump || sslBumpNeed_ == Ssl::bumpPeek || sslBumpNeed_ == Ssl::bumpStare; } |
e0c0d54c | 152 | /// set the sslBumpNeeded state |
08097970 | 153 | void sslBumpNeed(Ssl::BumpMode mode); |
807ecef2 | 154 | void sslBumpStart(); |
c8407295 | 155 | void sslBumpEstablish(Comm::Flag errflag); |
807ecef2 | 156 | #endif |
157 | ||
a83c6ed6 | 158 | #if USE_ADAPTATION |
de31d06f | 159 | |
160 | public: | |
a22e6cd3 | 161 | void startAdaptation(const Adaptation::ServiceGroupPointer &g); |
940307b9 | 162 | bool requestSatisfactionMode() const { return request_satisfaction_mode; } |
9d4d7c5e | 163 | |
32fd6d8a | 164 | private: |
f53969cc | 165 | /// Handles an adaptation client request failure. |
32fd6d8a | 166 | /// Bypasses the error if possible, or build an error reply. |
64b66b76 | 167 | void handleAdaptationFailure(int errDetail, bool bypassable = false); |
5f8252d2 | 168 | |
16b8a262 | 169 | // Adaptation::Initiator API |
3af10ac0 | 170 | virtual void noteAdaptationAnswer(const Adaptation::Answer &answer); |
63df1d28 | 171 | void handleAdaptedHeader(Http::Message *msg); |
3af10ac0 | 172 | void handleAdaptationBlock(const Adaptation::Answer &answer); |
79628299 | 173 | virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group); |
5f8252d2 | 174 | |
175 | // BodyConsumer API, called by BodyPipe | |
1cf238db | 176 | virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer); |
177 | virtual void noteBodyProductionEnded(BodyPipe::Pointer); | |
178 | virtual void noteBodyProducerAborted(BodyPipe::Pointer); | |
5f8252d2 | 179 | |
180 | void endRequestSatisfaction(); | |
0ad2b63b CT |
181 | /// called by StoreEntry when it has more buffer space available |
182 | void resumeBodyStorage(); | |
5f8252d2 | 183 | |
184 | private: | |
4299f876 | 185 | CbcPointer<Adaptation::Initiate> virginHeadSource; |
a83c6ed6 | 186 | BodyPipe::Pointer adaptedBodySource; |
5f8252d2 | 187 | |
b044675d | 188 | bool request_satisfaction_mode; |
57d55dfa | 189 | int64_t request_satisfaction_offset; |
de31d06f | 190 | #endif |
528b2c61 | 191 | }; |
192 | ||
193 | /* client http based routines */ | |
8a648e8d | 194 | char *clientConstructTraceEcho(ClientHttpRequest *); |
c0941a6a | 195 | |
8a648e8d FC |
196 | ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http); |
197 | int clientHttpRequestStatus(int fd, ClientHttpRequest const *http); | |
198 | void clientAccessCheck(ClientHttpRequest *); | |
528b2c61 | 199 | |
200 | /* ones that should be elsewhere */ | |
ac9f46af | 201 | void tunnelStart(ClientHttpRequest *); |
528b2c61 | 202 | |
c8be6d7b | 203 | #endif /* SQUID_CLIENTSIDEREQUEST_H */ |
f53969cc | 204 |