HttpRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 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 
39 class CachePeer;
40 class ConnStateData;
41 class Downloader;
42 
43 /* Http Request */
44 void httpRequestPack(void *obj, Packable *p);
45 
46 class HttpHdrRange;
47 
49 {
51 
52 public:
54 
56  HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath, const MasterXaction::Pointer &);
57  ~HttpRequest();
58  virtual void reset();
59 
60  void initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath);
61 
62  virtual HttpRequest *clone() const;
63 
67  bool maybeCacheable();
68 
69  bool conditional() const;
70 
72  bool canHandle1xx() const;
73 
76  char *canonicalCleanUrl() const;
77 
78 #if USE_ADAPTATION
82  Adaptation::History::Pointer adaptHistory(bool createIfNone = false) const;
84  void adaptHistoryImport(const HttpRequest &them);
85 #endif
86 #if ICAP_CLIENT
89 #endif
90 
91  /* If a request goes through several destinations, then the following two
92  * methods will be called several times, in destinations-dependent order. */
94  void prepForPeering(const CachePeer &peer);
96  void prepForDirect();
97 
98  void recordLookup(const Dns::LookupDetails &detail);
99 
101  void detailError(err_type aType, int aDetail);
103  void clearError();
104 
106  void manager(const CbcPointer<ConnStateData> &aMgr, const AccessLogEntryPointer &al);
107 
108 protected:
109  void clean();
110 
111  void init();
112 
113 public:
116 
117 private:
118 #if USE_ADAPTATION
120 #endif
121 #if ICAP_CLIENT
123 #endif
124 
125 public:
126 #if USE_AUTH
128 #endif
129 
131  const SBuf &effectiveRequestUri() const;
132 
140 
142 
144 
145  time_t ims;
146 
147  int imslen;
148 
150 
151 #if FOLLOW_X_FORWARDED_FOR
153 #endif /* FOLLOW_X_FORWARDED_FOR */
154 
156 
158 
159  int dnsWait;
160 
162  int errDetail;
163 
164  char *peer_login; /* Configured peer login:password */
165 
166  char *peer_host; /* Selected peer host*/
167 
168  time_t lastmod; /* Used on refreshes */
169 
172 
173  char *peer_domain; /* Configured peer forceddomain */
174 
175  String myportname; // Internal tag name= value from port this requests arrived in.
176 
177  String tag; /* Internal tag for this request */
178 
179  String extacl_user; /* User name returned by extacl lookup */
180 
181  String extacl_passwd; /* Password returned by extacl lookup */
182 
183  String extacl_log; /* String to be used for access.log purposes */
184 
185  String extacl_message; /* String to be used for error page purposes */
186 
187 #if FOLLOW_X_FORWARDED_FOR
188  String x_forwarded_for_iterator; /* XXX a list of IP addresses */
189 #endif /* FOLLOW_X_FORWARDED_FOR */
190 
193 
196 
197 public:
198  bool multipartRangeRequest() const;
199 
200  bool parseFirstLine(const char *start, const char *end);
201 
202  virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
203 
204  bool bodyNibbled() const; // the request has a [partially] consumed body
205 
206  int prefixLen() const;
207 
208  void swapOut(StoreEntry * e);
209 
210  void pack(Packable * p) const;
211 
212  static void httpRequestPack(void *obj, Packable *p);
213 
214  static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method = Http::METHOD_GET);
215 
217  static HttpRequest * FromUrlXXX(const char * url, const MasterXaction::Pointer &, const HttpRequestMethod &method = Http::METHOD_GET);
218 
220 
226  const SBuf storeId();
227 
234 
237 
240 
242  void ignoreRange(const char *reason);
243  int64_t getRangeOffsetLimit(); /* the result of this function gets cached in rangeOffsetLimit */
244 
248  bool hasNotes() const { return bool(theNotes) && !theNotes->empty(); }
249 
251 
254  bool parseHeader(Http1::Parser &hp);
257  bool parseHeader(const char *buffer, const size_t size);
258 
259 private:
260  mutable int64_t rangeOffsetLimit; /* caches the result of getRangeOffsetLimit */
261 
265 protected:
266  virtual void packFirstLineInto(Packable * p, bool full_uri) const;
267 
268  virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error);
269 
270  virtual void hdrCacheInit();
271 
272  virtual bool inheritProperties(const Http::Message *);
273 };
274 
275 class ConnStateData;
280 
284 
285 #endif /* SQUID_HTTPREQUEST_H */
286 
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
Definition: HttpRequest.h:239
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:605
HierarchyLogEntry hier
Definition: HttpRequest.h:157
err_type errType
Definition: HttpRequest.h:161
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:686
HttpHdrRange * range
Definition: HttpRequest.h:143
Ip::Address my_addr
Definition: HttpRequest.h:155
String extacl_log
Definition: HttpRequest.h:183
HttpRequest(const MasterXaction::Pointer &)
Definition: HttpRequest.cc:43
RefCount< HttpRequest > Pointer
Definition: HttpRequest.h:50
#define MEMPROXY_CLASS(CLASS)
int errDetail
errType-specific detail about the transaction error
Definition: HttpRequest.h:162
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
Definition: HttpRequest.h:171
Adaptation::Icap::History::Pointer icapHistory_
per-HTTP transaction info
Definition: HttpRequest.h:122
void initHTTP(const HttpRequestMethod &aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath)
Definition: HttpRequest.cc:69
Definition: SBuf.h:86
HttpRequestMethod method
Definition: HttpRequest.h:114
int prefixLen() const
Definition: HttpRequest.cc:372
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:195
Adaptation::History::Pointer adaptLogHistory() const
Returns possibly nil history, creating it if adapt. logging is enabled.
Definition: HttpRequest.cc:418
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
Definition: HttpRequest.cc:407
encapsulates DNS lookup results
Definition: LookupDetails.h:20
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:546
void prepForPeering(const CachePeer &peer)
get ready to be sent to the given cache_peer, including originserver
Definition: HttpRequest.cc:449
char * p
Definition: membanger.c:43
time_t ims
Definition: HttpRequest.h:145
const SBuf storeId()
Definition: HttpRequest.cc:694
void prepForDirect()
get ready to be sent directly to an origin server, excluding originserver
Definition: HttpRequest.cc:459
int64_t rangeOffsetLimit
Definition: HttpRequest.h:260
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:735
String extacl_message
Definition: HttpRequest.h:185
NotePairs::Pointer notes()
Definition: HttpRequest.cc:713
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:705
StatusCode
Definition: StatusCode.h:20
String extacl_passwd
Definition: HttpRequest.h:181
String store_id
Definition: HttpRequest.h:139
void adaptHistoryImport(const HttpRequest &them)
Makes their history ours, throwing on conflicts.
Definition: HttpRequest.cc:424
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:506
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:337
void pack(Packable *p) const
Definition: HttpRequest.cc:347
Ip::Address client_addr
Definition: HttpRequest.h:149
virtual bool inheritProperties(const Http::Message *)
Definition: HttpRequest.cc:216
bool bodyNibbled() const
Definition: HttpRequest.cc:443
char * peer_host
Definition: HttpRequest.h:166
virtual void packFirstLineInto(Packable *p, bool full_uri) const
Definition: HttpRequest.cc:490
String tag
Definition: HttpRequest.h:177
common parts of HttpRequest and HttpReply
Definition: Message.h:25
NotePairs::Pointer theNotes
Definition: HttpRequest.h:264
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:233
char * canonicalCleanUrl() const
Definition: HttpRequest.cc:775
bool parseHeader(Http1::Parser &hp)
Definition: HttpRequest.cc:672
static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:535
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:482
const Ip::Address * FindListeningPortAddress(const HttpRequest *, const AccessLogEntry *)
Definition: HttpRequest.cc:803
String x_forwarded_for_iterator
Definition: HttpRequest.h:188
static void httpRequestPack(void *obj, Packable *p)
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:646
virtual void reset()
Definition: HttpRequest.cc:170
void const char * buf
Definition: stub_helper.cc:16
void httpRequestPack(void *obj, Packable *p)
Definition: HttpRequest.cc:364
bool hasNotes() const
Definition: HttpRequest.h:248
RequestFlags flags
Definition: HttpRequest.h:141
bool maybeCacheable()
Definition: HttpRequest.cc:556
bool parseFirstLine(const char *start, const char *end)
Definition: HttpRequest.cc:297
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: HttpRequest.h:37
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:236
Definition: Uri.h:30
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Definition: HttpRequest.h:159
int64_t getRangeOffsetLimit()
Definition: HttpRequest.cc:619
void detailError(err_type aType, int aDetail)
sets error detail if no earlier detail was available
Definition: HttpRequest.cc:468
String extacl_user
Definition: HttpRequest.h:179
Adaptation::History::Pointer adaptHistory_
per-HTTP transaction info
Definition: HttpRequest.h:119
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:597
ProtocolType
Definition: ProtocolType.h:23
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
virtual HttpRequest * clone() const
Definition: HttpRequest.cc:177
bool multipartRangeRequest() const
Definition: HttpRequest.cc:437
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpRequest.cc:271
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &notes)
Definition: HttpRequest.cc:721
String myportname
Definition: HttpRequest.h:175
void init()
Definition: HttpRequest.cc:77
char * peer_login
Definition: HttpRequest.h:164
Ip::Address indirect_client_addr
Definition: HttpRequest.h:152
bool empty() const
Definition: Notes.h:248
time_t lastmod
Definition: HttpRequest.h:168
virtual void configureContentLengthInterpreter(Http::ContentLengthInterpreter &)
configures the interpreter as needed
Definition: HttpRequest.h:250
void clean()
Definition: HttpRequest.cc:123
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:192
virtual void hdrCacheInit()
Definition: HttpRequest.cc:382
int size
Definition: ModDevPoll.cc:77
bool canHandle1xx() const
whether the client is likely to be able to handle a 1xx reply
Definition: HttpRequest.cc:660
char * peer_domain
Definition: HttpRequest.h:173
err_type
Definition: err_type.h:12
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
Definition: HttpRequest.cc:392

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors