6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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.
35 #ifndef SQUID_CLIENTSIDEREQUEST_H
36 #define SQUID_CLIENTSIDEREQUEST_H
38 #include "squid-old.h"
39 #include "HttpHeader.h"
40 #include "clientStream.h"
41 #include "client_side.h"
42 #include "AccessLogEntry.h"
44 #include "base/AsyncJob.h"
47 #include "adaptation/forward.h"
48 #include "adaptation/Initiator.h"
53 /* client_side_request.c - client side request related routines (pure logic) */
54 extern int clientBeginRequest(const HttpRequestMethod
&, char const *, CSCB
*, CSD
*, ClientStreamData
, HttpHeader
const *, char *, size_t);
60 class ClientRequestContext
;
62 class ClientHttpRequest
64 : public Adaptation::Initiator
, // to start adaptation transactions
65 public BodyConsumer
// to receive reply bodies in request satisf. mode
70 void *operator new (size_t);
71 void operator delete (void *);
73 void *toCbdata() { return this; }
75 ClientHttpRequest(ConnStateData
*csd
);
77 /* Not implemented - present to prevent synthetic operations */
78 ClientHttpRequest(ClientHttpRequest
const &);
79 ClientHttpRequest
& operator=(ClientHttpRequest
const &);
81 String
rangeBoundaryStr() const;
83 void updateCounters();
85 _SQUID_INLINE_ MemObject
* memObject() const;
86 bool multipartRangeRequest() const;
87 void processRequest();
89 bool onlyIfCached()const;
90 bool gotEnough() const;
91 _SQUID_INLINE_ StoreEntry
*storeEntry() const;
92 void storeEntry(StoreEntry
*);
93 _SQUID_INLINE_ StoreEntry
*loggingEntry() const;
94 void loggingEntry(StoreEntry
*);
96 _SQUID_INLINE_ ConnStateData
* getConn() const;
97 _SQUID_INLINE_
void setConn(ConnStateData
*);
99 /** Details of the client socket which produced us.
100 * Treat as read-only for the lifetime of this HTTP request.
102 Comm::ConnectionPointer clientConnection
;
104 HttpRequest
*request
; /* Parsed URL ... */
114 HttpHdrRangeIter range_iter
; /* data for iterating thru range specs */
115 size_t req_sz
; /* raw request size on input, not current request size */
118 struct timeval start_time
;
119 AccessLogEntry::Pointer al
; ///< access.log entry
122 unsigned int accel
:1;
123 unsigned int intercepted
:1;
124 unsigned int spoof_client_ip
:1;
125 unsigned int internal
:1;
126 unsigned int done_copying
:1;
127 unsigned int purging
:1;
136 dlink_list client_stream
;
139 ClientRequestContext
*calloutContext
;
143 // AsyncJob virtual methods
144 virtual bool doneAll() const {
145 return Initiator::doneAll() &&
146 BodyConsumer::doneAll() && false;
151 CBDATA_CLASS(ClientHttpRequest
);
152 int64_t maxReplyBodySize_
;
154 StoreEntry
*loggingEntry_
;
155 ConnStateData
* conn_
;
158 /// whether (and how) the request needs to be bumped
159 Ssl::BumpMode sslBumpNeed_
;
162 /// returns raw sslBump mode value
163 Ssl::BumpMode
sslBumpNeed() const { return sslBumpNeed_
; }
164 /// returns true if and only if the request needs to be bumped
165 bool sslBumpNeeded() const { return sslBumpNeed_
== Ssl::bumpServerFirst
|| sslBumpNeed_
== Ssl::bumpClientFirst
; }
166 /// set the sslBumpNeeded state
167 void sslBumpNeed(Ssl::BumpMode mode
);
169 void sslBumpEstablish(comm_err_t errflag
);
175 void startAdaptation(const Adaptation::ServiceGroupPointer
&g
);
177 // private but exposed for ClientRequestContext
178 void handleAdaptationFailure(int errDetail
, bool bypassable
= false);
181 // Adaptation::Initiator API
182 virtual void noteAdaptationAnswer(const Adaptation::Answer
&answer
);
183 void handleAdaptedHeader(HttpMsg
*msg
);
184 void handleAdaptationBlock(const Adaptation::Answer
&answer
);
185 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group
);
187 // BodyConsumer API, called by BodyPipe
188 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer
);
189 virtual void noteBodyProductionEnded(BodyPipe::Pointer
);
190 virtual void noteBodyProducerAborted(BodyPipe::Pointer
);
192 void endRequestSatisfaction();
193 /// called by StoreEntry when it has more buffer space available
194 void resumeBodyStorage();
197 CbcPointer
<Adaptation::Initiate
> virginHeadSource
;
198 BodyPipe::Pointer adaptedBodySource
;
200 bool request_satisfaction_mode
;
201 int64_t request_satisfaction_offset
;
205 /* client http based routines */
206 SQUIDCEXTERN
char *clientConstructTraceEcho(ClientHttpRequest
*);
208 class ACLFilledChecklist
;
209 SQUIDCEXTERN ACLFilledChecklist
*clientAclChecklistCreate(const acl_access
* acl
,ClientHttpRequest
* http
);
210 SQUIDCEXTERN
int clientHttpRequestStatus(int fd
, ClientHttpRequest
const *http
);
211 SQUIDCEXTERN
void clientAccessCheck(ClientHttpRequest
*);
213 /* ones that should be elsewhere */
214 SQUIDCEXTERN
void redirectStart(ClientHttpRequest
*, RH
*, void *);
216 SQUIDCEXTERN
void tunnelStart(ClientHttpRequest
*, int64_t *, int *);
220 #include "client_side_request.cci"
223 #endif /* SQUID_CLIENTSIDEREQUEST_H */