2 * SQUID Web Proxy Cache http://www.squid-cache.org/
3 * ----------------------------------------------------------
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.
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.
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.
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.
30 #ifndef SQUID_CLIENTSIDEREQUEST_H
31 #define SQUID_CLIENTSIDEREQUEST_H
33 #include "HttpHeader.h"
34 #include "clientStream.h"
35 #include "client_side.h"
36 #include "AccessLogEntry.h"
38 #include "base/AsyncJob.h"
39 #include "HttpHeaderRange.h"
42 #include "adaptation/forward.h"
43 #include "adaptation/Initiator.h"
48 class ACLFilledChecklist
;
49 class ClientRequestContext
;
53 /* client_side_request.c - client side request related routines (pure logic) */
54 int clientBeginRequest(const HttpRequestMethod
&, char const *, CSCB
*, CSD
*, ClientStreamData
, HttpHeader
const *, char *, size_t);
56 class ClientHttpRequest
58 : public Adaptation::Initiator
, // to start adaptation transactions
59 public BodyConsumer
// to receive reply bodies in request satisf. mode
64 void *operator new (size_t);
65 void operator delete (void *);
67 void *toCbdata() { return this; }
69 ClientHttpRequest(ConnStateData
*csd
);
71 /* Not implemented - present to prevent synthetic operations */
72 ClientHttpRequest(ClientHttpRequest
const &);
73 ClientHttpRequest
& operator=(ClientHttpRequest
const &);
75 String
rangeBoundaryStr() const;
77 void updateCounters();
79 _SQUID_INLINE_ MemObject
* memObject() const;
80 bool multipartRangeRequest() const;
81 void processRequest();
83 bool onlyIfCached()const;
84 bool gotEnough() const;
85 _SQUID_INLINE_ StoreEntry
*storeEntry() const;
86 void storeEntry(StoreEntry
*);
87 _SQUID_INLINE_ StoreEntry
*loggingEntry() const;
88 void loggingEntry(StoreEntry
*);
90 _SQUID_INLINE_ ConnStateData
* getConn() const;
91 _SQUID_INLINE_
void setConn(ConnStateData
*);
93 /** Details of the client socket which produced us.
94 * Treat as read-only for the lifetime of this HTTP request.
96 Comm::ConnectionPointer clientConnection
;
98 HttpRequest
*request
; /* Parsed URL ... */
108 HttpHdrRangeIter range_iter
; /* data for iterating thru range specs */
109 size_t req_sz
; /* raw request size on input, not current request size */
112 struct timeval start_time
;
113 AccessLogEntry::Pointer al
; ///< access.log entry
116 unsigned int accel
:1;
117 unsigned int intercepted
:1;
118 unsigned int spoof_client_ip
:1;
119 unsigned int internal
:1;
120 unsigned int done_copying
:1;
121 unsigned int purging
:1;
130 dlink_list client_stream
;
133 ClientRequestContext
*calloutContext
;
137 // AsyncJob virtual methods
138 virtual bool doneAll() const {
139 return Initiator::doneAll() &&
140 BodyConsumer::doneAll() && false;
145 int64_t maxReplyBodySize_
;
147 StoreEntry
*loggingEntry_
;
148 ConnStateData
* conn_
;
151 /// whether (and how) the request needs to be bumped
152 Ssl::BumpMode sslBumpNeed_
;
155 /// returns raw sslBump mode value
156 Ssl::BumpMode
sslBumpNeed() const { return sslBumpNeed_
; }
157 /// returns true if and only if the request needs to be bumped
158 bool sslBumpNeeded() const { return sslBumpNeed_
== Ssl::bumpServerFirst
|| sslBumpNeed_
== Ssl::bumpClientFirst
; }
159 /// set the sslBumpNeeded state
160 void sslBumpNeed(Ssl::BumpMode mode
);
162 void sslBumpEstablish(comm_err_t errflag
);
168 void startAdaptation(const Adaptation::ServiceGroupPointer
&g
);
170 // private but exposed for ClientRequestContext
171 void handleAdaptationFailure(int errDetail
, bool bypassable
= false);
174 // Adaptation::Initiator API
175 virtual void noteAdaptationAnswer(const Adaptation::Answer
&answer
);
176 void handleAdaptedHeader(HttpMsg
*msg
);
177 void handleAdaptationBlock(const Adaptation::Answer
&answer
);
178 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group
);
180 // BodyConsumer API, called by BodyPipe
181 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer
);
182 virtual void noteBodyProductionEnded(BodyPipe::Pointer
);
183 virtual void noteBodyProducerAborted(BodyPipe::Pointer
);
185 void endRequestSatisfaction();
186 /// called by StoreEntry when it has more buffer space available
187 void resumeBodyStorage();
190 CbcPointer
<Adaptation::Initiate
> virginHeadSource
;
191 BodyPipe::Pointer adaptedBodySource
;
193 bool request_satisfaction_mode
;
194 int64_t request_satisfaction_offset
;
198 CBDATA_CLASS(ClientHttpRequest
);
201 /* client http based routines */
202 char *clientConstructTraceEcho(ClientHttpRequest
*);
204 ACLFilledChecklist
*clientAclChecklistCreate(const acl_access
* acl
,ClientHttpRequest
* http
);
205 int clientHttpRequestStatus(int fd
, ClientHttpRequest
const *http
);
206 void clientAccessCheck(ClientHttpRequest
*);
208 /* ones that should be elsewhere */
209 void redirectStart(ClientHttpRequest
*, RH
*, void *);
210 void tunnelStart(ClientHttpRequest
*, int64_t *, int *);
214 #include "client_side_request.cci"
217 #endif /* SQUID_CLIENTSIDEREQUEST_H */