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 "AccessLogEntry.h"
34 #include "acl/forward.h"
35 #include "client_side.h"
36 #include "clientStream.h"
37 #include "HttpHeaderRange.h"
41 #include "adaptation/forward.h"
42 #include "adaptation/Initiator.h"
46 class ClientRequestContext
;
50 /* client_side_request.c - client side request related routines (pure logic) */
51 int clientBeginRequest(const HttpRequestMethod
&, char const *, CSCB
*, CSD
*, ClientStreamData
, HttpHeader
const *, char *, size_t);
53 class ClientHttpRequest
55 : public Adaptation::Initiator
, // to start adaptation transactions
56 public BodyConsumer
// to receive reply bodies in request satisf. mode
61 ClientHttpRequest(ConnStateData
*csd
);
63 /* Not implemented - present to prevent synthetic operations */
64 ClientHttpRequest(ClientHttpRequest
const &);
65 ClientHttpRequest
& operator=(ClientHttpRequest
const &);
67 String
rangeBoundaryStr() const;
69 void updateCounters();
71 _SQUID_INLINE_ MemObject
* memObject() const;
72 bool multipartRangeRequest() const;
73 void processRequest();
75 bool onlyIfCached()const;
76 bool gotEnough() const;
77 _SQUID_INLINE_ StoreEntry
*storeEntry() const;
78 void storeEntry(StoreEntry
*);
79 _SQUID_INLINE_ StoreEntry
*loggingEntry() const;
80 void loggingEntry(StoreEntry
*);
82 _SQUID_INLINE_ ConnStateData
* getConn() const;
83 _SQUID_INLINE_
void setConn(ConnStateData
*);
85 /** Details of the client socket which produced us.
86 * Treat as read-only for the lifetime of this HTTP request.
88 Comm::ConnectionPointer clientConnection
;
90 HttpRequest
*request
; /* Parsed URL ... */
93 String store_id
; /* StoreID for transactions where the request member is nil */
101 HttpHdrRangeIter range_iter
; /* data for iterating thru range specs */
102 size_t req_sz
; /* raw request size on input, not current request size */
104 /// the processing tags associated with this request transaction.
105 // NP: still an enum so each stage altering it must take care when replacing it.
108 AccessLogEntry::Pointer al
; ///< access.log entry
112 //bool intercepted; //XXX: it's apparently never used.
113 //bool spoof_client_ip; //XXX: it's apparently never used.
120 Http::StatusCode status
;
125 dlink_list client_stream
;
128 ClientRequestContext
*calloutContext
;
132 // AsyncJob virtual methods
133 virtual bool doneAll() const {
134 return Initiator::doneAll() &&
135 BodyConsumer::doneAll() && false;
140 int64_t maxReplyBodySize_
;
142 StoreEntry
*loggingEntry_
;
143 ConnStateData
* conn_
;
146 /// whether (and how) the request needs to be bumped
147 Ssl::BumpMode sslBumpNeed_
;
150 /// returns raw sslBump mode value
151 Ssl::BumpMode
sslBumpNeed() const { return sslBumpNeed_
; }
152 /// returns true if and only if the request needs to be bumped
153 bool sslBumpNeeded() const { return sslBumpNeed_
== Ssl::bumpServerFirst
|| sslBumpNeed_
== Ssl::bumpClientFirst
|| sslBumpNeed_
== Ssl::bumpBump
|| sslBumpNeed_
== Ssl::bumpPeek
|| sslBumpNeed_
== Ssl::bumpStare
; }
154 /// set the sslBumpNeeded state
155 void sslBumpNeed(Ssl::BumpMode mode
);
157 void sslBumpEstablish(Comm::Flag errflag
);
163 void startAdaptation(const Adaptation::ServiceGroupPointer
&g
);
165 // private but exposed for ClientRequestContext
166 void handleAdaptationFailure(int errDetail
, bool bypassable
= false);
169 // Adaptation::Initiator API
170 virtual void noteAdaptationAnswer(const Adaptation::Answer
&answer
);
171 void handleAdaptedHeader(HttpMsg
*msg
);
172 void handleAdaptationBlock(const Adaptation::Answer
&answer
);
173 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group
);
175 // BodyConsumer API, called by BodyPipe
176 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer
);
177 virtual void noteBodyProductionEnded(BodyPipe::Pointer
);
178 virtual void noteBodyProducerAborted(BodyPipe::Pointer
);
180 void endRequestSatisfaction();
181 /// called by StoreEntry when it has more buffer space available
182 void resumeBodyStorage();
185 CbcPointer
<Adaptation::Initiate
> virginHeadSource
;
186 BodyPipe::Pointer adaptedBodySource
;
188 bool request_satisfaction_mode
;
189 int64_t request_satisfaction_offset
;
193 CBDATA_CLASS2(ClientHttpRequest
);
196 /* client http based routines */
197 char *clientConstructTraceEcho(ClientHttpRequest
*);
199 ACLFilledChecklist
*clientAclChecklistCreate(const acl_access
* acl
,ClientHttpRequest
* http
);
200 int clientHttpRequestStatus(int fd
, ClientHttpRequest
const *http
);
201 void clientAccessCheck(ClientHttpRequest
*);
203 /* ones that should be elsewhere */
204 void tunnelStart(ClientHttpRequest
*, int64_t *, int *, const AccessLogEntry::Pointer
&al
);
207 #include "client_side_request.cci"
211 #endif /* SQUID_CLIENTSIDEREQUEST_H */