HttpRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
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.
7  */
8 
9 #ifndef SQUID_HTTPREQUEST_H
10 #define SQUID_HTTPREQUEST_H
11 
12 #include "anyp/Uri.h"
13 #include "base/CbcPointer.h"
14 #include "dns/forward.h"
15 #include "err_type.h"
16 #include "HierarchyLogEntry.h"
17 #include "http/Message.h"
18 #include "http/RequestMethod.h"
19 #include "MasterXaction.h"
20 #include "Notes.h"
21 #include "RequestFlags.h"
22 
23 #if USE_AUTH
24 #include "auth/UserRequest.h"
25 #endif
26 #if USE_ADAPTATION
27 #include "adaptation/History.h"
28 #endif
29 #if ICAP_CLIENT
31 #endif
32 #if USE_SQUID_EUI
33 #include "eui/Eui48.h"
34 #include "eui/Eui64.h"
35 #endif
36 
37 class ConnStateData;
38 class Downloader;
41 
42 /* Http Request */
43 void httpRequestPack(void *obj, Packable *p);
44 
45 class HttpHdrRange;
46 
48 {
50 
51 public:
53 
55  HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath, const MasterXaction::Pointer &);
56  ~HttpRequest();
57  virtual void reset();
58 
59  void initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath);
60 
61  virtual HttpRequest *clone() const;
62 
66  bool maybeCacheable();
67 
68  bool conditional() const;
69 
71  bool canHandle1xx() const;
72 
73 #if USE_ADAPTATION
77  Adaptation::History::Pointer adaptHistory(bool createIfNone = false) const;
79  void adaptHistoryImport(const HttpRequest &them);
80 #endif
81 #if ICAP_CLIENT
84 #endif
85 
86  void recordLookup(const Dns::LookupDetails &detail);
87 
89  void detailError(err_type aType, int aDetail);
91  void clearError();
92 
94  void manager(const CbcPointer<ConnStateData> &aMgr, const AccessLogEntryPointer &al);
95 
96 protected:
97  void clean();
98 
99  void init();
100 
101 public:
104 
105 private:
106 #if USE_ADAPTATION
108 #endif
109 #if ICAP_CLIENT
111 #endif
112 
113 public:
114 #if USE_AUTH
116 #endif
117 
119  const SBuf &effectiveRequestUri() const;
120 
128 
130 
132 
133  time_t ims;
134 
135  int imslen;
136 
138 
139 #if FOLLOW_X_FORWARDED_FOR
141 #endif /* FOLLOW_X_FORWARDED_FOR */
142 
144 
146 
147  int dnsWait;
148 
150  int errDetail;
151 
152  char *peer_login; /* Configured peer login:password */
153 
154  char *peer_host; /* Selected peer host*/
155 
156  time_t lastmod; /* Used on refreshes */
157 
160 
161  char *peer_domain; /* Configured peer forceddomain */
162 
163  String myportname; // Internal tag name= value from port this requests arrived in.
164 
165  String tag; /* Internal tag for this request */
166 
167  String extacl_user; /* User name returned by extacl lookup */
168 
169  String extacl_passwd; /* Password returned by extacl lookup */
170 
171  String extacl_log; /* String to be used for access.log purposes */
172 
173  String extacl_message; /* String to be used for error page purposes */
174 
175 #if FOLLOW_X_FORWARDED_FOR
176  String x_forwarded_for_iterator; /* XXX a list of IP addresses */
177 #endif /* FOLLOW_X_FORWARDED_FOR */
178 
181 
184 
185 public:
186  bool multipartRangeRequest() const;
187 
188  bool parseFirstLine(const char *start, const char *end);
189 
190  virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
191 
192  bool bodyNibbled() const; // the request has a [partially] consumed body
193 
194  int prefixLen() const;
195 
196  void swapOut(StoreEntry * e);
197 
198  void pack(Packable * p) const;
199 
200  static void httpRequestPack(void *obj, Packable *p);
201 
202  static HttpRequest * FromUrl(const char * url, const MasterXaction::Pointer &, const HttpRequestMethod &method = Http::METHOD_GET);
203 
205 
211  const SBuf storeId();
212 
219 
222 
225 
227  void ignoreRange(const char *reason);
228  int64_t getRangeOffsetLimit(); /* the result of this function gets cached in rangeOffsetLimit */
229 
233  bool hasNotes() const { return bool(theNotes) && !theNotes->empty(); }
234 
235 private:
236  mutable int64_t rangeOffsetLimit; /* caches the result of getRangeOffsetLimit */
237 
241 protected:
242  virtual void packFirstLineInto(Packable * p, bool full_uri) const;
243 
244  virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error);
245 
246  virtual void hdrCacheInit();
247 
248  virtual bool inheritProperties(const Http::Message *);
249 };
250 
251 class ConnStateData;
256 
260 
261 #endif /* SQUID_HTTPREQUEST_H */
262 
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
Definition: HttpRequest.h:224
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:586
HierarchyLogEntry hier
Definition: HttpRequest.h:145
void pack(Packable *p) const
Definition: HttpRequest.cc:353
err_type errType
Definition: HttpRequest.h:149
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:653
HttpHdrRange * range
Definition: HttpRequest.h:131
Ip::Address my_addr
Definition: HttpRequest.h:143
String extacl_log
Definition: HttpRequest.h:171
HttpRequest(const MasterXaction::Pointer &)
Definition: HttpRequest.cc:41
RefCount< HttpRequest > Pointer
Definition: HttpRequest.h:49
#define MEMPROXY_CLASS(CLASS)
int errDetail
errType-specific detail about the transaction error
Definition: HttpRequest.h:150
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
Definition: HttpRequest.h:159
Adaptation::Icap::History::Pointer icapHistory_
per-HTTP transaction info
Definition: HttpRequest.h:110
void initHTTP(const HttpRequestMethod &aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath)
Definition: HttpRequest.cc:67
Definition: SBuf.h:86
bool canHandle1xx() const
whether the client is likely to be able to handle a 1xx reply
Definition: HttpRequest.cc:641
HttpRequestMethod method
Definition: HttpRequest.h:102
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void error(char *format,...)
bool forcedBodyContinuation
whether we have responded with HTTP 100 or FTP 150 already
Definition: HttpRequest.h:183
encapsulates DNS lookup results
Definition: LookupDetails.h:20
char * p
Definition: membanger.c:43
time_t ims
Definition: HttpRequest.h:133
const SBuf storeId()
Definition: HttpRequest.cc:661
int64_t rangeOffsetLimit
Definition: HttpRequest.h:236
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:702
String extacl_message
Definition: HttpRequest.h:173
NotePairs::Pointer notes()
Definition: HttpRequest.cc:680
StatusCode
Definition: StatusCode.h:20
String extacl_passwd
Definition: HttpRequest.h:169
String store_id
Definition: HttpRequest.h:127
void adaptHistoryImport(const HttpRequest &them)
Makes their history ours, throwing on conflicts.
Definition: HttpRequest.cc:430
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
Definition: HttpRequest.cc:413
bool bodyNibbled() const
Definition: HttpRequest.cc:449
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:343
bool empty() const
Definition: Notes.h:242
NotePairs::Pointer notes()
virtual HttpRequest * clone() const
Definition: HttpRequest.cc:175
Ip::Address client_addr
Definition: HttpRequest.h:137
virtual bool inheritProperties(const Http::Message *)
Definition: HttpRequest.cc:214
char * peer_host
Definition: HttpRequest.h:154
String tag
Definition: HttpRequest.h:165
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:672
common parts of HttpRequest and HttpReply
Definition: Message.h:24
NotePairs::Pointer theNotes
Definition: HttpRequest.h:240
AnyP::Uri url
the request URI
Definition: HttpRequest.h:103
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:218
bool hasNotes() const
Definition: HttpRequest.h:233
int prefixLen() const
Definition: HttpRequest.cc:378
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:469
const Ip::Address * FindListeningPortAddress(const HttpRequest *, const AccessLogEntry *)
Definition: HttpRequest.cc:764
String x_forwarded_for_iterator
Definition: HttpRequest.h:176
static HttpRequest * FromUrl(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:522
static void httpRequestPack(void *obj, Packable *p)
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:627
virtual void reset()
Definition: HttpRequest.cc:168
void const char * buf
Definition: stub_helper.cc:16
void httpRequestPack(void *obj, Packable *p)
Definition: HttpRequest.cc:370
Adaptation::History::Pointer adaptLogHistory() const
Returns possibly nil history, creating it if adapt. logging is enabled.
Definition: HttpRequest.cc:424
RequestFlags flags
Definition: HttpRequest.h:129
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
Definition: HttpRequest.cc:398
bool maybeCacheable()
Definition: HttpRequest.cc:537
bool parseFirstLine(const char *start, const char *end)
Definition: HttpRequest.cc:295
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: HttpRequest.h:39
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:221
Definition: Uri.h:30
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Definition: HttpRequest.h:147
int64_t getRangeOffsetLimit()
Definition: HttpRequest.cc:600
void detailError(err_type aType, int aDetail)
sets error detail if no earlier detail was available
Definition: HttpRequest.cc:455
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:578
String extacl_user
Definition: HttpRequest.h:167
Adaptation::History::Pointer adaptHistory_
per-HTTP transaction info
Definition: HttpRequest.h:107
virtual void packFirstLineInto(Packable *p, bool full_uri) const
Definition: HttpRequest.cc:477
ProtocolType
Definition: ProtocolType.h:22
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:115
bool multipartRangeRequest() const
Definition: HttpRequest.cc:443
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpRequest.cc:269
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &notes)
Definition: HttpRequest.cc:688
String myportname
Definition: HttpRequest.h:163
void init()
Definition: HttpRequest.cc:75
char * peer_login
Definition: HttpRequest.h:152
Ip::Address indirect_client_addr
Definition: HttpRequest.h:140
time_t lastmod
Definition: HttpRequest.h:156
void clean()
Definition: HttpRequest.cc:121
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:493
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:180
virtual void hdrCacheInit()
Definition: HttpRequest.cc:388
char * peer_domain
Definition: HttpRequest.h:161
err_type
Definition: err_type.h:12

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors