2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef SQUID_CLIENTSIDEREQUEST_H
10 #define SQUID_CLIENTSIDEREQUEST_H
12 #include "AccessLogEntry.h"
13 #include "acl/forward.h"
14 #include "client_side.h"
15 #include "clientStream.h"
16 #include "HttpHeaderRange.h"
20 #include "adaptation/forward.h"
21 #include "adaptation/Initiator.h"
25 class ClientRequestContext
;
29 /* client_side_request.c - client side request related routines (pure logic) */
30 int clientBeginRequest(const HttpRequestMethod
&, char const *, CSCB
*, CSD
*, ClientStreamData
, HttpHeader
const *, char *, size_t);
32 class ClientHttpRequest
34 : public Adaptation::Initiator
, // to start adaptation transactions
35 public BodyConsumer
// to receive reply bodies in request satisf. mode
38 CBDATA_CLASS(ClientHttpRequest
);
41 ClientHttpRequest(ConnStateData
*csd
);
43 /* Not implemented - present to prevent synthetic operations */
44 ClientHttpRequest(ClientHttpRequest
const &);
45 ClientHttpRequest
& operator=(ClientHttpRequest
const &);
47 String
rangeBoundaryStr() const;
49 void updateCounters();
51 _SQUID_INLINE_ MemObject
* memObject() const;
52 bool multipartRangeRequest() const;
53 void processRequest();
55 bool onlyIfCached()const;
56 bool gotEnough() const;
57 _SQUID_INLINE_ StoreEntry
*storeEntry() const;
58 void storeEntry(StoreEntry
*);
59 _SQUID_INLINE_ StoreEntry
*loggingEntry() const;
60 void loggingEntry(StoreEntry
*);
62 _SQUID_INLINE_ ConnStateData
* getConn() const;
63 _SQUID_INLINE_
void setConn(ConnStateData
*);
65 /** Details of the client socket which produced us.
66 * Treat as read-only for the lifetime of this HTTP request.
68 Comm::ConnectionPointer clientConnection
;
70 HttpRequest
*request
; /* Parsed URL ... */
73 String store_id
; /* StoreID for transactions where the request member is nil */
81 HttpHdrRangeIter range_iter
; /* data for iterating thru range specs */
82 size_t req_sz
; /* raw request size on input, not current request size */
84 /// the processing tags associated with this request transaction.
85 // NP: still an enum so each stage altering it must take care when replacing it.
88 AccessLogEntry::Pointer al
; ///< access.log entry
92 //bool intercepted; //XXX: it's apparently never used.
93 //bool spoof_client_ip; //XXX: it's apparently never used.
100 Http::StatusCode status
;
105 dlink_list client_stream
;
108 ClientRequestContext
*calloutContext
;
111 /// Build an error reply. For use with the callouts.
112 void calloutsError(const err_type error
, const int errDetail
);
115 // AsyncJob virtual methods
116 virtual bool doneAll() const {
117 return Initiator::doneAll() &&
118 BodyConsumer::doneAll() && false;
123 int64_t maxReplyBodySize_
;
125 StoreEntry
*loggingEntry_
;
126 ConnStateData
* conn_
;
129 /// whether (and how) the request needs to be bumped
130 Ssl::BumpMode sslBumpNeed_
;
133 /// returns raw sslBump mode value
134 Ssl::BumpMode
sslBumpNeed() const { return sslBumpNeed_
; }
135 /// returns true if and only if the request needs to be bumped
136 bool sslBumpNeeded() const { return sslBumpNeed_
== Ssl::bumpServerFirst
|| sslBumpNeed_
== Ssl::bumpClientFirst
|| sslBumpNeed_
== Ssl::bumpBump
|| sslBumpNeed_
== Ssl::bumpPeek
|| sslBumpNeed_
== Ssl::bumpStare
; }
137 /// set the sslBumpNeeded state
138 void sslBumpNeed(Ssl::BumpMode mode
);
140 void sslBumpEstablish(Comm::Flag errflag
);
146 void startAdaptation(const Adaptation::ServiceGroupPointer
&g
);
149 /// Handles an adaptation client request failure.
150 /// Bypasses the error if possible, or build an error reply.
151 void handleAdaptationFailure(int errDetail
, bool bypassable
= false);
153 // Adaptation::Initiator API
154 virtual void noteAdaptationAnswer(const Adaptation::Answer
&answer
);
155 void handleAdaptedHeader(HttpMsg
*msg
);
156 void handleAdaptationBlock(const Adaptation::Answer
&answer
);
157 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group
);
159 // BodyConsumer API, called by BodyPipe
160 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer
);
161 virtual void noteBodyProductionEnded(BodyPipe::Pointer
);
162 virtual void noteBodyProducerAborted(BodyPipe::Pointer
);
164 void endRequestSatisfaction();
165 /// called by StoreEntry when it has more buffer space available
166 void resumeBodyStorage();
169 CbcPointer
<Adaptation::Initiate
> virginHeadSource
;
170 BodyPipe::Pointer adaptedBodySource
;
172 bool request_satisfaction_mode
;
173 int64_t request_satisfaction_offset
;
177 /* client http based routines */
178 char *clientConstructTraceEcho(ClientHttpRequest
*);
180 ACLFilledChecklist
*clientAclChecklistCreate(const acl_access
* acl
,ClientHttpRequest
* http
);
181 int clientHttpRequestStatus(int fd
, ClientHttpRequest
const *http
);
182 void clientAccessCheck(ClientHttpRequest
*);
184 /* ones that should be elsewhere */
185 void tunnelStart(ClientHttpRequest
*, int64_t *, int *, const AccessLogEntry::Pointer
&al
);
188 #include "client_side_request.cci"
192 #endif /* SQUID_CLIENTSIDEREQUEST_H */