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