]> git.ipfire.org Git - thirdparty/squid.git/blame - src/client_side_request.h
renamed snmp_request_t to SnmpRequest and moved to own header
[thirdparty/squid.git] / src / client_side_request.h
CommitLineData
c8be6d7b 1/*
c8be6d7b 2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
4 *
5 * Squid is the result of efforts by numerous individuals from
6 * the Internet community; see the CONTRIBUTORS file for full
7 * details. Many organizations have provided support for Squid's
8 * development; see the SPONSORS file for full details. Squid is
9 * Copyrighted (C) 2001 by the Regents of the University of
10 * California; see the COPYRIGHT file for full details. Squid
11 * incorporates software developed and/or copyrighted by other
12 * sources; see the CREDITS file for full details.
13 *
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
26ac0430 18 *
c8be6d7b 19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
26ac0430 23 *
c8be6d7b 24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
27 *
28 */
29
30#ifndef SQUID_CLIENTSIDEREQUEST_H
31#define SQUID_CLIENTSIDEREQUEST_H
32
528b2c61 33#include "HttpHeader.h"
34#include "clientStream.h"
a2ac85d9 35#include "client_side.h"
450e0c10 36#include "AccessLogEntry.h"
b1b15292 37#include "dlink.h"
d1e045c3 38#include "base/AsyncJob.h"
43ca19e0 39#include "HttpHeaderRange.h"
528b2c61 40
a83c6ed6
AR
41#if USE_ADAPTATION
42#include "adaptation/forward.h"
43#include "adaptation/Initiator.h"
de31d06f 44
45class HttpMsg;
46#endif
47
c8be6d7b 48/* client_side_request.c - client side request related routines (pure logic) */
8a648e8d 49int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
c8be6d7b 50
90f396d5 51class MemObject;
62e76326 52
924f73bc 53class ConnStateData;
54
de31d06f 55class ClientRequestContext;
56
62e76326 57class ClientHttpRequest
a83c6ed6 58#if USE_ADAPTATION
e1381638
AJ
59 : public Adaptation::Initiator, // to start adaptation transactions
60 public BodyConsumer // to receive reply bodies in request satisf. mode
5f8252d2 61#endif
62e76326 62{
63
528b2c61 64public:
65 void *operator new (size_t);
66 void operator delete (void *);
a83c6ed6 67#if USE_ADAPTATION
1cf238db 68 void *toCbdata() { return this; }
69#endif
be364179 70 ClientHttpRequest(ConnStateData *csd);
528b2c61 71 ~ClientHttpRequest();
72 /* Not implemented - present to prevent synthetic operations */
73 ClientHttpRequest(ClientHttpRequest const &);
74 ClientHttpRequest& operator=(ClientHttpRequest const &);
62e76326 75
30abd221 76 String rangeBoundaryStr() const;
528b2c61 77 void freeResources();
78 void updateCounters();
79 void logRequest();
86a2f789 80 _SQUID_INLINE_ MemObject * memObject() const;
528b2c61 81 bool multipartRangeRequest() const;
8e2745f4 82 void processRequest();
83 void httpStart();
0655fa4d 84 bool onlyIfCached()const;
85 bool gotEnough() const;
86a2f789 86 _SQUID_INLINE_ StoreEntry *storeEntry() const;
87 void storeEntry(StoreEntry *);
0976f8db 88 _SQUID_INLINE_ StoreEntry *loggingEntry() const;
89 void loggingEntry(StoreEntry *);
0655fa4d 90
4063e8b1 91 _SQUID_INLINE_ ConnStateData * getConn() const;
1cf238db 92 _SQUID_INLINE_ void setConn(ConnStateData *);
be364179 93
be364179
AJ
94 /** Details of the client socket which produced us.
95 * Treat as read-only for the lifetime of this HTTP request.
96 */
97 Comm::ConnectionPointer clientConnection;
98
190154cf 99 HttpRequest *request; /* Parsed URL ... */
528b2c61 100 char *uri;
101 char *log_uri;
62e76326 102
26ac0430 103 struct {
47f6e231 104 int64_t offset;
105 int64_t size;
62e76326 106 size_t headers_sz;
3d0ac046 107 } out;
62e76326 108
528b2c61 109 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
110 size_t req_sz; /* raw request size on input, not current request size */
528b2c61 111 log_type logType;
62e76326 112
1cf238db 113 struct timeval start_time;
41ebd397 114 AccessLogEntry::Pointer al; ///< access.log entry
62e76326 115
26ac0430 116 struct {
3d0ac046 117 unsigned int accel:1;
2ad20b4f 118 unsigned int intercepted:1;
c12ca4dd 119 unsigned int spoof_client_ip:1;
3d0ac046
HN
120 unsigned int internal:1;
121 unsigned int done_copying:1;
122 unsigned int purging:1;
123 } flags;
62e76326 124
26ac0430 125 struct {
62e76326 126 http_status status;
127 char *location;
3d0ac046 128 } redirect;
62e76326 129
528b2c61 130 dlink_node active;
131 dlink_list client_stream;
132 int mRangeCLen();
62e76326 133
de31d06f 134 ClientRequestContext *calloutContext;
135 void doCallouts();
136
a83c6ed6
AR
137#if USE_ADAPTATION
138 // AsyncJob virtual methods
26ac0430
AJ
139 virtual bool doneAll() const {
140 return Initiator::doneAll() &&
141 BodyConsumer::doneAll() && false;
142 }
1cf238db 143#endif
144
528b2c61 145private:
47f6e231 146 int64_t maxReplyBodySize_;
86a2f789 147 StoreEntry *entry_;
0976f8db 148 StoreEntry *loggingEntry_;
1cf238db 149 ConnStateData * conn_;
de31d06f 150
807ecef2 151#if USE_SSL
caf3666d 152 /// whether (and how) the request needs to be bumped
08097970 153 Ssl::BumpMode sslBumpNeed_;
e0c0d54c 154
807ecef2 155public:
08097970
AR
156 /// returns raw sslBump mode value
157 Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; }
158 /// returns true if and only if the request needs to be bumped
159 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst; }
e0c0d54c 160 /// set the sslBumpNeeded state
08097970 161 void sslBumpNeed(Ssl::BumpMode mode);
807ecef2 162 void sslBumpStart();
163 void sslBumpEstablish(comm_err_t errflag);
164#endif
165
a83c6ed6 166#if USE_ADAPTATION
de31d06f 167
168public:
a22e6cd3 169 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
9d4d7c5e 170
171 // private but exposed for ClientRequestContext
64b66b76 172 void handleAdaptationFailure(int errDetail, bool bypassable = false);
5f8252d2 173
174private:
16b8a262 175 // Adaptation::Initiator API
3af10ac0
AR
176 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
177 void handleAdaptedHeader(HttpMsg *msg);
178 void handleAdaptationBlock(const Adaptation::Answer &answer);
79628299 179 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
5f8252d2 180
181 // BodyConsumer API, called by BodyPipe
1cf238db 182 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
183 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
184 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
5f8252d2 185
186 void endRequestSatisfaction();
0ad2b63b
CT
187 /// called by StoreEntry when it has more buffer space available
188 void resumeBodyStorage();
5f8252d2 189
190private:
4299f876 191 CbcPointer<Adaptation::Initiate> virginHeadSource;
a83c6ed6 192 BodyPipe::Pointer adaptedBodySource;
5f8252d2 193
b044675d 194 bool request_satisfaction_mode;
57d55dfa 195 int64_t request_satisfaction_offset;
de31d06f 196#endif
c7bf588b
FC
197
198private:
199 CBDATA_CLASS(ClientHttpRequest);
528b2c61 200};
201
202/* client http based routines */
8a648e8d 203char *clientConstructTraceEcho(ClientHttpRequest *);
c0941a6a
AR
204
205class ACLFilledChecklist;
8a648e8d
FC
206ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
207int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
208void clientAccessCheck(ClientHttpRequest *);
528b2c61 209
210/* ones that should be elsewhere */
8a648e8d
FC
211void redirectStart(ClientHttpRequest *, RH *, void *);
212void tunnelStart(ClientHttpRequest *, int64_t *, int *);
528b2c61 213
32d002cb 214#if _USE_INLINE_
4b9bb50a 215#include "Store.h"
86a2f789 216#include "client_side_request.cci"
217#endif
218
c8be6d7b 219#endif /* SQUID_CLIENTSIDEREQUEST_H */