]> 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/*
4ac4a490 2 * Copyright (C) 1996-2017 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
cc8c4af2
AJ
75 struct Out {
76 Out() : offset(0), size(0), headers_sz(0) {}
77
47f6e231 78 int64_t offset;
ac9f46af 79 uint64_t size;
62e76326 80 size_t headers_sz;
3d0ac046 81 } out;
62e76326 82
f53969cc
SM
83 HttpHdrRangeIter range_iter; /* data for iterating thru range specs */
84 size_t req_sz; /* raw request size on input, not current request size */
62e76326 85
02c8dde5
AJ
86 /// the processing tags associated with this request transaction.
87 // NP: still an enum so each stage altering it must take care when replacing it.
88 LogTags logType;
62e76326 89
41ebd397 90 AccessLogEntry::Pointer al; ///< access.log entry
62e76326 91
cc8c4af2
AJ
92 struct Flags {
93 Flags() : accel(false), internal(false), done_copying(false), purging(false) {}
94
be4d35dc 95 bool accel;
be4d35dc
FC
96 bool internal;
97 bool done_copying;
98 bool purging;
3d0ac046 99 } flags;
62e76326 100
cc8c4af2
AJ
101 struct Redirect {
102 Redirect() : status(Http::scNone), location(NULL) {}
103
955394ce 104 Http::StatusCode status;
62e76326 105 char *location;
3d0ac046 106 } redirect;
62e76326 107
528b2c61 108 dlink_node active;
109 dlink_list client_stream;
110 int mRangeCLen();
62e76326 111
de31d06f 112 ClientRequestContext *calloutContext;
113 void doCallouts();
114
32fd6d8a
CT
115 /// Build an error reply. For use with the callouts.
116 void calloutsError(const err_type error, const int errDetail);
117
a83c6ed6
AR
118#if USE_ADAPTATION
119 // AsyncJob virtual methods
26ac0430
AJ
120 virtual bool doneAll() const {
121 return Initiator::doneAll() &&
122 BodyConsumer::doneAll() && false;
123 }
1cf238db 124#endif
125
528b2c61 126private:
47f6e231 127 int64_t maxReplyBodySize_;
86a2f789 128 StoreEntry *entry_;
0976f8db 129 StoreEntry *loggingEntry_;
1cf238db 130 ConnStateData * conn_;
de31d06f 131
cb4f4424 132#if USE_OPENSSL
caf3666d 133 /// whether (and how) the request needs to be bumped
08097970 134 Ssl::BumpMode sslBumpNeed_;
e0c0d54c 135
807ecef2 136public:
08097970
AR
137 /// returns raw sslBump mode value
138 Ssl::BumpMode sslBumpNeed() const { return sslBumpNeed_; }
139 /// returns true if and only if the request needs to be bumped
5d65362c 140 bool sslBumpNeeded() const { return sslBumpNeed_ == Ssl::bumpServerFirst || sslBumpNeed_ == Ssl::bumpClientFirst || sslBumpNeed_ == Ssl::bumpBump || sslBumpNeed_ == Ssl::bumpPeek || sslBumpNeed_ == Ssl::bumpStare; }
e0c0d54c 141 /// set the sslBumpNeeded state
08097970 142 void sslBumpNeed(Ssl::BumpMode mode);
807ecef2 143 void sslBumpStart();
c8407295 144 void sslBumpEstablish(Comm::Flag errflag);
807ecef2 145#endif
146
a83c6ed6 147#if USE_ADAPTATION
de31d06f 148
149public:
a22e6cd3 150 void startAdaptation(const Adaptation::ServiceGroupPointer &g);
940307b9 151 bool requestSatisfactionMode() const { return request_satisfaction_mode; }
9d4d7c5e 152
32fd6d8a 153private:
f53969cc 154 /// Handles an adaptation client request failure.
32fd6d8a 155 /// Bypasses the error if possible, or build an error reply.
64b66b76 156 void handleAdaptationFailure(int errDetail, bool bypassable = false);
5f8252d2 157
16b8a262 158 // Adaptation::Initiator API
3af10ac0
AR
159 virtual void noteAdaptationAnswer(const Adaptation::Answer &answer);
160 void handleAdaptedHeader(HttpMsg *msg);
161 void handleAdaptationBlock(const Adaptation::Answer &answer);
79628299 162 virtual void noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer group);
5f8252d2 163
164 // BodyConsumer API, called by BodyPipe
1cf238db 165 virtual void noteMoreBodyDataAvailable(BodyPipe::Pointer);
166 virtual void noteBodyProductionEnded(BodyPipe::Pointer);
167 virtual void noteBodyProducerAborted(BodyPipe::Pointer);
5f8252d2 168
169 void endRequestSatisfaction();
0ad2b63b
CT
170 /// called by StoreEntry when it has more buffer space available
171 void resumeBodyStorage();
5f8252d2 172
173private:
4299f876 174 CbcPointer<Adaptation::Initiate> virginHeadSource;
a83c6ed6 175 BodyPipe::Pointer adaptedBodySource;
5f8252d2 176
b044675d 177 bool request_satisfaction_mode;
57d55dfa 178 int64_t request_satisfaction_offset;
de31d06f 179#endif
528b2c61 180};
181
182/* client http based routines */
8a648e8d 183char *clientConstructTraceEcho(ClientHttpRequest *);
c0941a6a 184
8a648e8d
FC
185ACLFilledChecklist *clientAclChecklistCreate(const acl_access * acl,ClientHttpRequest * http);
186int clientHttpRequestStatus(int fd, ClientHttpRequest const *http);
187void clientAccessCheck(ClientHttpRequest *);
528b2c61 188
189/* ones that should be elsewhere */
ac9f46af 190void tunnelStart(ClientHttpRequest *);
528b2c61 191
32d002cb 192#if _USE_INLINE_
86a2f789 193#include "client_side_request.cci"
602d9612 194#include "Store.h"
86a2f789 195#endif
196
c8be6d7b 197#endif /* SQUID_CLIENTSIDEREQUEST_H */
f53969cc 198