]> git.ipfire.org Git - thirdparty/squid.git/blame - src/client_side_request.h
Link HttpRequest with ConnStateData early
[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
b1b15292 38#include "squid.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
75 ClientHttpRequest(ConnStateData *);
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 *);
190154cf 98 HttpRequest *request; /* Parsed URL ... */
528b2c61 99 char *uri;
100 char *log_uri;
62e76326 101
26ac0430 102 struct {
47f6e231 103 int64_t offset;
104 int64_t size;
62e76326 105 size_t headers_sz;
3d0ac046 106 } out;
62e76326 107
528b2c61 108 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
109 size_t req_sz; /* raw request size on input, not current request size */
528b2c61 110 log_type logType;
62e76326 111
1cf238db 112 struct timeval start_time;
528b2c61 113 AccessLogEntry al;
62e76326 114
26ac0430 115 struct {
3d0ac046 116 unsigned int accel:1;
2ad20b4f 117 unsigned int intercepted:1;
c12ca4dd 118 unsigned int spoof_client_ip:1;
3d0ac046
HN
119 unsigned int internal:1;
120 unsigned int done_copying:1;
121 unsigned int purging:1;
122 } flags;
62e76326 123
26ac0430 124 struct {
62e76326 125 http_status status;
126 char *location;
3d0ac046 127 } redirect;
62e76326 128
528b2c61 129 dlink_node active;
130 dlink_list client_stream;
131 int mRangeCLen();
62e76326 132
de31d06f 133 ClientRequestContext *calloutContext;
134 void doCallouts();
135
a83c6ed6
AR
136#if USE_ADAPTATION
137 // AsyncJob virtual methods
26ac0430
AJ
138 virtual bool doneAll() const {
139 return Initiator::doneAll() &&
140 BodyConsumer::doneAll() && false;
141 }
1cf238db 142#endif
143
528b2c61 144private:
145 CBDATA_CLASS(ClientHttpRequest);
47f6e231 146 int64_t maxReplyBodySize_;
86a2f789 147 StoreEntry *entry_;
0976f8db 148 StoreEntry *loggingEntry_;
1cf238db 149 ConnStateData * conn_;
de31d06f 150
807ecef2 151#if USE_SSL
152public:
153 bool sslBumpNeeded() const;
154 void sslBumpStart();
155 void sslBumpEstablish(comm_err_t errflag);
156#endif
157
a83c6ed6 158#if USE_ADAPTATION
de31d06f 159
160public:
a22e6cd3 161 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
9d4d7c5e 162
163 // private but exposed for ClientRequestContext
64b66b76 164 void handleAdaptationFailure(int errDetail, bool bypassable = false);
5f8252d2 165
166private:
16b8a262 167 // Adaptation::Initiator API
3af10ac0
AR
168 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
169 void handleAdaptedHeader(HttpMsg *msg);
170 void handleAdaptationBlock(const Adaptation::Answer &answer);
5f8252d2 171
172 // BodyConsumer API, called by BodyPipe
1cf238db 173 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
174 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
175 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
5f8252d2 176
177 void endRequestSatisfaction();
178
179private:
4299f876 180 CbcPointer<Adaptation::Initiate> virginHeadSource;
a83c6ed6 181 BodyPipe::Pointer adaptedBodySource;
5f8252d2 182
b044675d 183 bool request_satisfaction_mode;
57d55dfa 184 int64_t request_satisfaction_offset;
de31d06f 185#endif
528b2c61 186};
187
188/* client http based routines */
59a1efb2 189SQUIDCEXTERN char *clientConstructTraceEcho(ClientHttpRequest *);
c0941a6a
AR
190
191class ACLFilledChecklist;
192SQUIDCEXTERN ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
59a1efb2 193SQUIDCEXTERN int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
8e2745f4 194SQUIDCEXTERN void clientAccessCheck(ClientHttpRequest *);
528b2c61 195
196/* ones that should be elsewhere */
59a1efb2 197SQUIDCEXTERN void redirectStart(ClientHttpRequest *, RH *, void *);
528b2c61 198
47f6e231 199SQUIDCEXTERN void tunnelStart(ClientHttpRequest *, int64_t *, int *);
528b2c61 200
32d002cb 201#if _USE_INLINE_
4b9bb50a 202#include "Store.h"
86a2f789 203#include "client_side_request.cci"
204#endif
205
c8be6d7b 206#endif /* SQUID_CLIENTSIDEREQUEST_H */