]> git.ipfire.org Git - thirdparty/squid.git/blame - src/client_side_request.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / client_side_request.h
CommitLineData
c8be6d7b 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
c8be6d7b 3 *
bbc27441
AJ
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.
c8be6d7b 7 */
8
9#ifndef SQUID_CLIENTSIDEREQUEST_H
10#define SQUID_CLIENTSIDEREQUEST_H
11
450e0c10 12#include "AccessLogEntry.h"
602d9612 13#include "acl/forward.h"
a2ac85d9 14#include "client_side.h"
602d9612 15#include "clientStream.h"
43ca19e0 16#include "HttpHeaderRange.h"
02c8dde5 17#include "LogTags.h"
528b2c61 18
a83c6ed6
AR
19#if USE_ADAPTATION
20#include "adaptation/forward.h"
21#include "adaptation/Initiator.h"
de31d06f 22class HttpMsg;
23#endif
24
c6983ec7
FC
25class ClientRequestContext;
26class ConnStateData;
90f396d5 27class MemObject;
62e76326 28
c6983ec7
FC
29/* client_side_request.c - client side request related routines (pure logic) */
30int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t);
924f73bc 31
62e76326 32class ClientHttpRequest
a83c6ed6 33#if USE_ADAPTATION
f53969cc
SM
34 : public Adaptation::Initiator, // to start adaptation transactions
35 public BodyConsumer // to receive reply bodies in request satisf. mode
5f8252d2 36#endif
62e76326 37{
5c2f68b7 38 CBDATA_CLASS(ClientHttpRequest);
62e76326 39
528b2c61 40public:
be364179 41 ClientHttpRequest(ConnStateData *csd);
528b2c61 42 ~ClientHttpRequest();
43 /* Not implemented - present to prevent synthetic operations */
44 ClientHttpRequest(ClientHttpRequest const &);
45 ClientHttpRequest& operator=(ClientHttpRequest const &);
62e76326 46
30abd221 47 String rangeBoundaryStr() const;
528b2c61 48 void freeResources();
49 void updateCounters();
50 void logRequest();
86a2f789 51 _SQUID_INLINE_ MemObject * memObject() const;
528b2c61 52 bool multipartRangeRequest() const;
8e2745f4 53 void processRequest();
54 void httpStart();
0655fa4d 55 bool onlyIfCached()const;
56 bool gotEnough() const;
86a2f789 57 _SQUID_INLINE_ StoreEntry *storeEntry() const;
58 void storeEntry(StoreEntry *);
0976f8db 59 _SQUID_INLINE_ StoreEntry *loggingEntry() const;
60 void loggingEntry(StoreEntry *);
0655fa4d 61
4063e8b1 62 _SQUID_INLINE_ ConnStateData * getConn() const;
1cf238db 63 _SQUID_INLINE_ void setConn(ConnStateData *);
be364179 64
be364179
AJ
65 /** Details of the client socket which produced us.
66 * Treat as read-only for the lifetime of this HTTP request.
67 */
68 Comm::ConnectionPointer clientConnection;
69
f53969cc 70 HttpRequest *request; /* Parsed URL ... */
528b2c61 71 char *uri;
72 char *log_uri;
a8a0b1c2 73 String store_id; /* StoreID for transactions where the request member is nil */
62e76326 74
26ac0430 75 struct {
47f6e231 76 int64_t offset;
77 int64_t size;
62e76326 78 size_t headers_sz;
3d0ac046 79 } out;
62e76326 80
f53969cc
SM
81 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
82 size_t req_sz; /* raw request size on input, not current request size */
62e76326 83
02c8dde5
AJ
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.
86 LogTags logType;
62e76326 87
41ebd397 88 AccessLogEntry::Pointer al; ///< access.log entry
62e76326 89
26ac0430 90 struct {
be4d35dc
FC
91 bool accel;
92 //bool intercepted; //XXX: it's apparently never used.
93 //bool spoof_client_ip; //XXX: it's apparently never used.
94 bool internal;
95 bool done_copying;
96 bool purging;
3d0ac046 97 } flags;
62e76326 98
26ac0430 99 struct {
955394ce 100 Http::StatusCode status;
62e76326 101 char *location;
3d0ac046 102 } redirect;
62e76326 103
528b2c61 104 dlink_node active;
105 dlink_list client_stream;
106 int mRangeCLen();
62e76326 107
de31d06f 108 ClientRequestContext *calloutContext;
109 void doCallouts();
110
32fd6d8a
CT
111 /// Build an error reply. For use with the callouts.
112 void calloutsError(const err_type error, const int errDetail);
113
a83c6ed6
AR
114#if USE_ADAPTATION
115 // AsyncJob virtual methods
26ac0430
AJ
116 virtual bool doneAll() const {
117 return Initiator::doneAll() &&
118 BodyConsumer::doneAll() && false;
119 }
1cf238db 120#endif
121
528b2c61 122private:
47f6e231 123 int64_t maxReplyBodySize_;
86a2f789 124 StoreEntry *entry_;
0976f8db 125 StoreEntry *loggingEntry_;
1cf238db 126 ConnStateData * conn_;
de31d06f 127
cb4f4424 128#if USE_OPENSSL
caf3666d 129 /// whether (and how) the request needs to be bumped
08097970 130 Ssl::BumpMode sslBumpNeed_;
e0c0d54c 131
807ecef2 132public:
08097970
AR
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
5d65362c 136 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst || sslBumpNeed_ == Ssl::bumpBump || sslBumpNeed_ == Ssl::bumpPeek || sslBumpNeed_ == Ssl::bumpStare; }
e0c0d54c 137 /// set the sslBumpNeeded state
08097970 138 void sslBumpNeed(Ssl::BumpMode mode);
807ecef2 139 void sslBumpStart();
c8407295 140 void sslBumpEstablish(Comm::Flag errflag);
807ecef2 141#endif
142
a83c6ed6 143#if USE_ADAPTATION
de31d06f 144
145public:
a22e6cd3 146 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
9d4d7c5e 147
32fd6d8a 148private:
f53969cc 149 /// Handles an adaptation client request failure.
32fd6d8a 150 /// Bypasses the error if possible, or build an error reply.
64b66b76 151 void handleAdaptationFailure(int errDetail, bool bypassable = false);
5f8252d2 152
16b8a262 153 // Adaptation::Initiator API
3af10ac0
AR
154 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
155 void handleAdaptedHeader(HttpMsg *msg);
156 void handleAdaptationBlock(const Adaptation::Answer &answer);
79628299 157 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
5f8252d2 158
159 // BodyConsumer API, called by BodyPipe
1cf238db 160 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
161 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
162 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
5f8252d2 163
164 void endRequestSatisfaction();
0ad2b63b
CT
165 /// called by StoreEntry when it has more buffer space available
166 void resumeBodyStorage();
5f8252d2 167
168private:
4299f876 169 CbcPointer<Adaptation::Initiate> virginHeadSource;
a83c6ed6 170 BodyPipe::Pointer adaptedBodySource;
5f8252d2 171
b044675d 172 bool request_satisfaction_mode;
57d55dfa 173 int64_t request_satisfaction_offset;
de31d06f 174#endif
528b2c61 175};
176
177/* client http based routines */
8a648e8d 178char *clientConstructTraceEcho(ClientHttpRequest *);
c0941a6a 179
8a648e8d
FC
180ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
181int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
182void clientAccessCheck(ClientHttpRequest *);
528b2c61 183
184/* ones that should be elsewhere */
06521a10 185void tunnelStart(ClientHttpRequest *, int64_t *, int *, const AccessLogEntry::Pointer &al);
528b2c61 186
32d002cb 187#if _USE_INLINE_
86a2f789 188#include "client_side_request.cci"
602d9612 189#include "Store.h"
86a2f789 190#endif
191
c8be6d7b 192#endif /* SQUID_CLIENTSIDEREQUEST_H */
f53969cc 193