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 
75  char *canonicalCleanUrl() const;
76 
77 #if USE_ADAPTATION
81  Adaptation::History::Pointer adaptHistory(bool createIfNone = false) const;
83  void adaptHistoryImport(const HttpRequest &them);
84 #endif
85 #if ICAP_CLIENT
88 #endif
89 
90  void recordLookup(const Dns::LookupDetails &detail);
91 
93  void detailError(err_type aType, int aDetail);
95  void clearError();
96 
98  void manager(const CbcPointer<ConnStateData> &aMgr, const AccessLogEntryPointer &al);
99 
100 protected:
101  void clean();
102 
103  void init();
104 
105 public:
108 
109 private:
110 #if USE_ADAPTATION
112 #endif
113 #if ICAP_CLIENT
115 #endif
116 
117 public:
118 #if USE_AUTH
120 #endif
121 
123  const SBuf &effectiveRequestUri() const;
124 
132 
134 
136 
137  time_t ims;
138 
139  int imslen;
140 
142 
143 #if FOLLOW_X_FORWARDED_FOR
145 #endif /* FOLLOW_X_FORWARDED_FOR */
146 
148 
150 
151  int dnsWait;
152 
154  int errDetail;
155 
156  char *peer_login; /* Configured peer login:password */
157 
158  char *peer_host; /* Selected peer host*/
159 
160  time_t lastmod; /* Used on refreshes */
161 
164 
165  char *peer_domain; /* Configured peer forceddomain */
166 
167  String myportname; // Internal tag name= value from port this requests arrived in.
168 
169  String tag; /* Internal tag for this request */
170 
171  String extacl_user; /* User name returned by extacl lookup */
172 
173  String extacl_passwd; /* Password returned by extacl lookup */
174 
175  String extacl_log; /* String to be used for access.log purposes */
176 
177  String extacl_message; /* String to be used for error page purposes */
178 
179 #if FOLLOW_X_FORWARDED_FOR
180  String x_forwarded_for_iterator; /* XXX a list of IP addresses */
181 #endif /* FOLLOW_X_FORWARDED_FOR */
182 
185 
188 
189 public:
190  bool multipartRangeRequest() const;
191 
192  bool parseFirstLine(const char *start, const char *end);
193 
194  virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
195 
196  bool bodyNibbled() const; // the request has a [partially] consumed body
197 
198  int prefixLen() const;
199 
200  void swapOut(StoreEntry * e);
201 
202  void pack(Packable * p) const;
203 
204  static void httpRequestPack(void *obj, Packable *p);
205 
206  static HttpRequest * FromUrl(const char * url, const MasterXaction::Pointer &, const HttpRequestMethod &method = Http::METHOD_GET);
207 
209 
215  const SBuf storeId();
216 
223 
226 
229 
231  void ignoreRange(const char *reason);
232  int64_t getRangeOffsetLimit(); /* the result of this function gets cached in rangeOffsetLimit */
233 
237  bool hasNotes() const { return bool(theNotes) && !theNotes->empty(); }
238 
240 
243  bool parseHeader(Http1::Parser &hp);
246  bool parseHeader(const char *buffer, const size_t size);
247 
248 private:
249  mutable int64_t rangeOffsetLimit; /* caches the result of getRangeOffsetLimit */
250 
254 protected:
255  virtual void packFirstLineInto(Packable * p, bool full_uri) const;
256 
257  virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error);
258 
259  virtual void hdrCacheInit();
260 
261  virtual bool inheritProperties(const Http::Message *);
262 };
263 
264 class ConnStateData;
269 
273 
274 #endif /* SQUID_HTTPREQUEST_H */
275 
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
Definition: HttpRequest.h:228
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:587
HierarchyLogEntry hier
Definition: HttpRequest.h:149
void pack(Packable *p) const
Definition: HttpRequest.cc:354
err_type errType
Definition: HttpRequest.h:153
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:668
HttpHdrRange * range
Definition: HttpRequest.h:135
Ip::Address my_addr
Definition: HttpRequest.h:147
String extacl_log
Definition: HttpRequest.h:175
HttpRequest(const MasterXaction::Pointer &)
Definition: HttpRequest.cc:42
RefCount< HttpRequest > Pointer
Definition: HttpRequest.h:49
#define MEMPROXY_CLASS(CLASS)
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &helperNotes)
Definition: HttpRequest.cc:703
int errDetail
errType-specific detail about the transaction error
Definition: HttpRequest.h:154
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
Definition: HttpRequest.h:163
Adaptation::Icap::History::Pointer icapHistory_
per-HTTP transaction info
Definition: HttpRequest.h:114
void initHTTP(const HttpRequestMethod &aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath)
Definition: HttpRequest.cc:68
Definition: SBuf.h:86
bool canHandle1xx() const
whether the client is likely to be able to handle a 1xx reply
Definition: HttpRequest.cc:642
HttpRequestMethod method
Definition: HttpRequest.h:106
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:187
encapsulates DNS lookup results
Definition: LookupDetails.h:20
char * p
Definition: membanger.c:43
time_t ims
Definition: HttpRequest.h:137
const SBuf storeId()
Definition: HttpRequest.cc:676
char * canonicalCleanUrl() const
Definition: HttpRequest.cc:757
int64_t rangeOffsetLimit
Definition: HttpRequest.h:249
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:717
String extacl_message
Definition: HttpRequest.h:177
NotePairs::Pointer notes()
Definition: HttpRequest.cc:695
StatusCode
Definition: StatusCode.h:20
String extacl_passwd
Definition: HttpRequest.h:173
String store_id
Definition: HttpRequest.h:131
void adaptHistoryImport(const HttpRequest &them)
Makes their history ours, throwing on conflicts.
Definition: HttpRequest.cc:431
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
Definition: HttpRequest.cc:414
bool bodyNibbled() const
Definition: HttpRequest.cc:450
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:344
bool empty() const
Definition: Notes.h:242
NotePairs::Pointer notes()
virtual HttpRequest * clone() const
Definition: HttpRequest.cc:176
Ip::Address client_addr
Definition: HttpRequest.h:141
virtual bool inheritProperties(const Http::Message *)
Definition: HttpRequest.cc:215
char * peer_host
Definition: HttpRequest.h:158
String tag
Definition: HttpRequest.h:169
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:687
common parts of HttpRequest and HttpReply
Definition: Message.h:25
NotePairs::Pointer theNotes
Definition: HttpRequest.h:253
AnyP::Uri url
the request URI
Definition: HttpRequest.h:107
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:222
bool parseHeader(Http1::Parser &hp)
Definition: HttpRequest.cc:654
bool hasNotes() const
Definition: HttpRequest.h:237
int prefixLen() const
Definition: HttpRequest.cc:379
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:470
String x_forwarded_for_iterator
Definition: HttpRequest.h:180
static HttpRequest * FromUrl(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:523
static void httpRequestPack(void *obj, Packable *p)
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:628
virtual void reset()
Definition: HttpRequest.cc:169
void const char * buf
Definition: stub_helper.cc:16
Adaptation::History::Pointer adaptLogHistory() const
Returns possibly nil history, creating it if adapt. logging is enabled.
Definition: HttpRequest.cc:425
RequestFlags flags
Definition: HttpRequest.h:133
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
Definition: HttpRequest.cc:399
bool maybeCacheable()
Definition: HttpRequest.cc:538
bool parseFirstLine(const char *start, const char *end)
Definition: HttpRequest.cc:296
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:225
void httpRequestPack(void *obj, Packable *p)
Definition: HttpRequest.cc:371
Definition: Uri.h:30
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Definition: HttpRequest.h:151
int64_t getRangeOffsetLimit()
Definition: HttpRequest.cc:601
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:785
void detailError(err_type aType, int aDetail)
sets error detail if no earlier detail was available
Definition: HttpRequest.cc:456
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:579
String extacl_user
Definition: HttpRequest.h:171
Adaptation::History::Pointer adaptHistory_
per-HTTP transaction info
Definition: HttpRequest.h:111
virtual void packFirstLineInto(Packable *p, bool full_uri) const
Definition: HttpRequest.cc:478
ProtocolType
Definition: ProtocolType.h:22
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:119
RefCount< AccessLogEntry > AccessLogEntryPointer
Definition: icap_log.h:15
bool multipartRangeRequest() const
Definition: HttpRequest.cc:444
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpRequest.cc:270
String myportname
Definition: HttpRequest.h:167
void init()
Definition: HttpRequest.cc:76
char * peer_login
Definition: HttpRequest.h:156
Ip::Address indirect_client_addr
Definition: HttpRequest.h:144
time_t lastmod
Definition: HttpRequest.h:160
virtual void configureContentLengthInterpreter(Http::ContentLengthInterpreter &)
configures the interpreter as needed
Definition: HttpRequest.h:239
void clean()
Definition: HttpRequest.cc:122
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:494
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:184
virtual void hdrCacheInit()
Definition: HttpRequest.cc:389
int size
Definition: ModDevPoll.cc:77
char * peer_domain
Definition: HttpRequest.h:165
err_type
Definition: err_type.h:12

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors