HttpRequest.cc
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 /* DEBUG: section 73 HTTP Request */
10 
11 #include "squid.h"
12 #include "AccessLogEntry.h"
13 #include "acl/AclSizeLimit.h"
14 #include "acl/FilledChecklist.h"
15 #include "CachePeer.h"
16 #include "client_side.h"
17 #include "client_side_request.h"
18 #include "dns/LookupDetails.h"
19 #include "Downloader.h"
20 #include "err_detail_type.h"
21 #include "globals.h"
22 #include "gopher.h"
23 #include "http.h"
25 #include "http/one/RequestParser.h"
26 #include "http/Stream.h"
27 #include "HttpHdrCc.h"
28 #include "HttpHeaderRange.h"
29 #include "HttpRequest.h"
30 #include "log/Config.h"
31 #include "MemBuf.h"
32 #include "sbuf/StringConvert.h"
33 #include "SquidConfig.h"
34 #include "Store.h"
35 
36 #if USE_AUTH
37 #include "auth/UserRequest.h"
38 #endif
39 #if ICAP_CLIENT
41 #endif
42 
44  Http::Message(hoRequest),
45  masterXaction(mx)
46 {
47  assert(mx);
48  init();
49 }
50 
51 HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aSchemeImg, const char *aUrlpath, const MasterXaction::Pointer &mx) :
53  masterXaction(mx)
54 {
55  assert(mx);
56  static unsigned int id = 1;
57  debugs(93,7, HERE << "constructed, this=" << this << " id=" << ++id);
58  init();
59  initHTTP(aMethod, aProtocol, aSchemeImg, aUrlpath);
60 }
61 
63 {
64  clean();
65  debugs(93,7, HERE << "destructed, this=" << this);
66 }
67 
68 void
69 HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aSchemeImg, const char *aUrlpath)
70 {
71  method = aMethod;
72  url.setScheme(aProtocol, aSchemeImg);
73  url.path(aUrlpath);
74 }
75 
76 void
78 {
80  url.clear();
81 #if USE_AUTH
83 #endif
84  flags = RequestFlags();
85  range = NULL;
86  ims = -1;
87  imslen = 0;
88  lastmod = -1;
90  my_addr.setEmpty();
91  body_pipe = NULL;
92  // hier
93  dnsWait = -1;
94  errType = ERR_NONE;
96  peer_login = NULL; // not allocated/deallocated by this class
97  peer_domain = NULL; // not allocated/deallocated by this class
98  peer_host = NULL;
99  vary_headers = SBuf();
101  tag = null_string;
102 #if USE_AUTH
105 #endif
109 #if FOLLOW_X_FORWARDED_FOR
111 #endif /* FOLLOW_X_FORWARDED_FOR */
112 #if USE_ADAPTATION
114 #endif
115 #if ICAP_CLIENT
116  icapHistory_ = NULL;
117 #endif
118  rangeOffsetLimit = -2; //a value of -2 means not checked yet
119  forcedBodyContinuation = false;
120 }
121 
122 void
124 {
125  // we used to assert that the pipe is NULL, but now the request only
126  // points to a pipe that is owned and initiated by another object.
127  body_pipe = NULL;
128 #if USE_AUTH
130 #endif
132  url.clear();
133 
134  header.clean();
135 
136  if (cache_control) {
137  delete cache_control;
139  }
140 
141  if (range) {
142  delete range;
143  range = NULL;
144  }
145 
146  myportname.clean();
147 
148  theNotes = nullptr;
149 
150  tag.clean();
151 #if USE_AUTH
152  extacl_user.clean();
154 #endif
155  extacl_log.clean();
156 
158 
159  etag.clean();
160 
161 #if USE_ADAPTATION
163 #endif
164 #if ICAP_CLIENT
165  icapHistory_ = NULL;
166 #endif
167 }
168 
169 void
171 {
172  clean();
173  init();
174 }
175 
176 HttpRequest *
178 {
180  copy->method = method;
181  // TODO: move common cloning clone to Msg::copyTo() or copy ctor
182  copy->header.append(&header);
183  copy->hdrCacheInit();
184  copy->hdr_sz = hdr_sz;
185  copy->http_ver = http_ver;
186  copy->pstate = pstate; // TODO: should we assert a specific state here?
187  copy->body_pipe = body_pipe;
188 
189  copy->url = url;
190 
191  // range handled in hdrCacheInit()
192  copy->ims = ims;
193  copy->imslen = imslen;
194  copy->hier = hier; // Is it safe to copy? Should we?
195 
196  copy->errType = errType;
197 
198  // XXX: what to do with copy->peer_login?
199 
200  copy->lastmod = lastmod;
201  copy->etag = etag;
202  copy->vary_headers = vary_headers;
203  // XXX: what to do with copy->peer_domain?
204 
205  copy->tag = tag;
206  copy->extacl_log = extacl_log;
208 
209  const bool inheritWorked = copy->inheritProperties(this);
210  assert(inheritWorked);
211 
212  return copy;
213 }
214 
215 bool
217 {
218  const HttpRequest* aReq = dynamic_cast<const HttpRequest*>(aMsg);
219  if (!aReq)
220  return false;
221 
222  client_addr = aReq->client_addr;
223 #if FOLLOW_X_FORWARDED_FOR
225 #endif
226  my_addr = aReq->my_addr;
227 
228  dnsWait = aReq->dnsWait;
229 
230 #if USE_ADAPTATION
231  adaptHistory_ = aReq->adaptHistory();
232 #endif
233 #if ICAP_CLIENT
234  icapHistory_ = aReq->icapHistory();
235 #endif
236 
237  // This may be too conservative for the 204 No Content case
238  // may eventually need cloneNullAdaptationImmune() for that.
240 
241  errType = aReq->errType;
242  errDetail = aReq->errDetail;
243 #if USE_AUTH
245  extacl_user = aReq->extacl_user;
247 #endif
248 
249  myportname = aReq->myportname;
250 
252 
253  // main property is which connection the request was received on (if any)
255 
256  downloader = aReq->downloader;
257 
258  theNotes = aReq->theNotes;
259 
260  sources = aReq->sources;
261  return true;
262 }
263 
270 bool
271 HttpRequest::sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
272 {
273  // content is long enough to possibly hold a reply
274  // 2 being magic size of a 1-byte request method plus space delimiter
275  if (hdr_len < 2) {
276  // this is ony a real error if the headers apparently complete.
277  if (hdr_len > 0) {
278  debugs(58, 3, HERE << "Too large request header (" << hdr_len << " bytes)");
279  *error = Http::scInvalidHeader;
280  }
281  return false;
282  }
283 
284  /* See if the request buffer starts with a non-whitespace HTTP request 'method'. */
286  m.HttpRequestMethodXXX(buf);
287  if (m == Http::METHOD_NONE) {
288  debugs(73, 3, "HttpRequest::sanityCheckStartLine: did not find HTTP request method");
289  *error = Http::scInvalidHeader;
290  return false;
291  }
292 
293  return true;
294 }
295 
296 bool
297 HttpRequest::parseFirstLine(const char *start, const char *end)
298 {
300 
301  if (method == Http::METHOD_NONE)
302  return false;
303 
304  // XXX: performance regression, strcspn() over the method bytes a second time.
305  // cheaper than allocate+copy+deallocate cycle to SBuf convert a piece of start.
306  const char *t = start + strcspn(start, w_space);
307 
308  start = t + strspn(t, w_space); // skip w_space after method
309 
310  const char *ver = findTrailingHTTPVersion(start, end);
311 
312  if (ver) {
313  end = ver - 1;
314 
315  while (xisspace(*end)) // find prev non-space
316  --end;
317 
318  ++end; // back to space
319 
320  if (2 != sscanf(ver + 5, "%d.%d", &http_ver.major, &http_ver.minor)) {
321  debugs(73, DBG_IMPORTANT, "parseRequestLine: Invalid HTTP identifier.");
322  return false;
323  }
324  } else {
325  http_ver.major = 0;
326  http_ver.minor = 9;
327  }
328 
329  if (end < start) // missing URI
330  return false;
331 
332  return url.parse(method, SBuf(start, size_t(end-start)));
333 }
334 
335 /* swaps out request using httpRequestPack */
336 void
338 {
339  assert(e);
340  e->buffer();
341  pack(e);
342  e->flush();
343 }
344 
345 /* packs request-line and headers, appends <crlf> terminator */
346 void
348 {
349  assert(p);
350  /* pack request-line */
351  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
354  /* headers */
355  header.packInto(p);
356  /* trailer */
357  p->append("\r\n", 2);
358 }
359 
360 /*
361  * A wrapper for debugObj()
362  */
363 void
365 {
366  HttpRequest *request = static_cast<HttpRequest*>(obj);
367  request->pack(p);
368 }
369 
370 /* returns the length of request line + headers + crlf */
371 int
373 {
374  return method.image().length() + 1 +
375  url.path().length() + 1 +
376  4 + 1 + 3 + 2 +
377  header.len + 2;
378 }
379 
380 /* sync this routine when you update HttpRequest struct */
381 void
383 {
385 
386  assert(!range);
387  range = header.getRange();
388 }
389 
390 #if ICAP_CLIENT
393 {
394  if (!icapHistory_) {
395  if (Log::TheConfig.hasIcapToken || IcapLogfileStatus == LOG_ENABLE) {
397  debugs(93,4, HERE << "made " << icapHistory_ << " for " << this);
398  }
399  }
400 
401  return icapHistory_;
402 }
403 #endif
404 
405 #if USE_ADAPTATION
407 HttpRequest::adaptHistory(bool createIfNone) const
408 {
409  if (!adaptHistory_ && createIfNone) {
411  debugs(93,4, HERE << "made " << adaptHistory_ << " for " << this);
412  }
413 
414  return adaptHistory_;
415 }
416 
419 {
420  return HttpRequest::adaptHistory(Log::TheConfig.hasAdaptToken);
421 }
422 
423 void
425 {
426  if (!adaptHistory_) {
427  adaptHistory_ = them.adaptHistory_; // may be nil
428  } else {
429  // check that histories did not diverge
430  Must(!them.adaptHistory_ || them.adaptHistory_ == adaptHistory_);
431  }
432 }
433 
434 #endif
435 
436 bool
438 {
439  return (range && range->specs.size() > 1);
440 }
441 
442 bool
444 {
445  return body_pipe != NULL && body_pipe->consumedSize() > 0;
446 }
447 
448 void
450 {
451  // XXX: Saving two pointers to memory controlled by an independent object.
452  peer_login = peer.login;
453  peer_domain = peer.domain;
455  debugs(11, 4, this << " to " << peer.host << (!peer.options.originserver ? " proxy" : " origin"));
456 }
457 
458 void
460 {
461  peer_login = nullptr;
462  peer_domain = nullptr;
463  flags.auth_no_keytab = false;
464  debugs(11, 4, this);
465 }
466 
467 void
469 {
470  if (errType || errDetail)
471  debugs(11, 5, HERE << "old error details: " << errType << '/' << errDetail);
472  debugs(11, 5, HERE << "current error details: " << aType << '/' << aDetail);
473  // checking type and detail separately may cause inconsistency, but
474  // may result in more details available if they only become available later
475  if (!errType)
476  errType = aType;
477  if (!errDetail)
478  errDetail = aDetail;
479 }
480 
481 void
483 {
484  debugs(11, 7, HERE << "old error details: " << errType << '/' << errDetail);
485  errType = ERR_NONE;
487 }
488 
489 void
491 {
492  const SBuf tmp(full_uri ? effectiveRequestUri() : url.path());
493 
494  // form HTTP request-line
495  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
497  SQUIDSBUFPRINT(tmp),
499 }
500 
501 /*
502  * Indicate whether or not we would expect an entity-body
503  * along with this request
504  */
505 bool
506 HttpRequest::expectingBody(const HttpRequestMethod &, int64_t &theSize) const
507 {
508  bool expectBody = false;
509 
510  /*
511  * Note: Checks for message validity is in clientIsContentLengthValid().
512  * this just checks if a entity-body is expected based on HTTP message syntax
513  */
514  if (header.chunked()) {
515  expectBody = true;
516  theSize = -1;
517  } else if (content_length >= 0) {
518  expectBody = true;
519  theSize = content_length;
520  } else {
521  expectBody = false;
522  // theSize undefined
523  }
524 
525  return expectBody;
526 }
527 
528 /*
529  * Create a Request from a URL and METHOD.
530  *
531  * If the METHOD is CONNECT, then a host:port pair is looked for instead of a URL.
532  * If the request cannot be created cleanly, NULL is returned
533  */
534 HttpRequest *
536 {
537  std::unique_ptr<HttpRequest> req(new HttpRequest(mx));
538  if (req->url.parse(method, url)) {
539  req->method = method;
540  return req.release();
541  }
542  return nullptr;
543 }
544 
545 HttpRequest *
547 {
548  return FromUrl(SBuf(url), mx, method);
549 }
550 
555 bool
557 {
558  // Intercepted request with Host: header which cannot be trusted.
559  // Because it failed verification, or someone bypassed the security tests
560  // we cannot cache the reponse for sharing between clients.
561  // TODO: update cache to store for particular clients only (going to same Host: and destination IP)
563  return false;
564 
565  switch (url.getScheme()) {
566  case AnyP::PROTO_HTTP:
567  case AnyP::PROTO_HTTPS:
568  if (!method.respMaybeCacheable())
569  return false;
570 
571  // RFC 7234 section 5.2.1.5:
572  // "cache MUST NOT store any part of either this request or any response to it"
573  //
574  // NP: refresh_pattern ignore-no-store only applies to response messages
575  // this test is handling request message CC header.
577  return false;
578  break;
579 
580  case AnyP::PROTO_GOPHER:
581  if (!gopherCachable(this))
582  return false;
583  break;
584 
586  return false;
587 
588  //case AnyP::PROTO_FTP:
589  default:
590  break;
591  }
592 
593  return true;
594 }
595 
596 bool
598 {
599  return flags.ims ||
602 }
603 
604 void
606 {
607  if (dns.wait >= 0) { // known delay
608  if (dnsWait >= 0) { // have recorded DNS wait before
609  debugs(78, 7, this << " " << dnsWait << " += " << dns);
610  dnsWait += dns.wait;
611  } else {
612  debugs(78, 7, this << " " << dns);
613  dnsWait = dns.wait;
614  }
615  }
616 }
617 
618 int64_t
620 {
621  /* -2 is the starting value of rangeOffsetLimit.
622  * If it is -2, that means we haven't checked it yet.
623  * Otherwise, return the current value */
624  if (rangeOffsetLimit != -2)
625  return rangeOffsetLimit;
626 
627  rangeOffsetLimit = 0; // default value for rangeOffsetLimit
628 
629  ACLFilledChecklist ch(NULL, this, NULL);
630  ch.src_addr = client_addr;
631  ch.my_addr = my_addr;
632 
633  for (AclSizeLimit *l = Config.rangeOffsetLimit; l; l = l -> next) {
634  /* if there is no ACL list or if the ACLs listed match use this limit value */
635  if (!l->aclList || ch.fastCheck(l->aclList).allowed()) {
636  rangeOffsetLimit = l->size; // may be -1
637  debugs(58, 4, rangeOffsetLimit);
638  break;
639  }
640  }
641 
642  return rangeOffsetLimit;
643 }
644 
645 void
646 HttpRequest::ignoreRange(const char *reason)
647 {
648  if (range) {
649  debugs(73, 3, static_cast<void*>(range) << " for " << reason);
650  delete range;
651  range = NULL;
652  }
653  // Some callers also reset isRanged but it may not be safe for all callers:
654  // isRanged is used to determine whether a weak ETag comparison is allowed,
655  // and that check should not ignore the Range header if it was present.
656  // TODO: Some callers also delete HDR_RANGE, HDR_REQUEST_RANGE. Should we?
657 }
658 
659 bool
661 {
662  // old clients do not support 1xx unless they sent Expect: 100-continue
663  // (we reject all other Http::HdrType::EXPECT values so just check for Http::HdrType::EXPECT)
665  return false;
666 
667  // others must support 1xx control messages
668  return true;
669 }
670 
671 bool
673 {
675  return Message::parseHeader(hp, clen);
676 }
677 
678 bool
679 HttpRequest::parseHeader(const char *buffer, const size_t size)
680 {
682  return header.parse(buffer, size, clen);
683 }
684 
687 {
689  return clientConnectionManager.get();
690  return NULL;
691 }
692 
693 const SBuf
695 {
696  if (store_id.size() != 0) {
697  debugs(73, 3, "sent back store_id: " << store_id);
698  return StringToSBuf(store_id);
699  }
700  debugs(73, 3, "sent back effectiveRequestUrl: " << effectiveRequestUri());
701  return effectiveRequestUri();
702 }
703 
704 const SBuf &
706 {
708  return url.authority(true); // host:port
709  return url.absolute();
710 }
711 
714 {
715  if (!theNotes)
716  theNotes = new NotePairs;
717  return theNotes;
718 }
719 
720 void
722 {
723  // Tag client connection if the helper responded with clt_conn_tag=tag.
724  const char *cltTag = "clt_conn_tag";
725  if (const char *connTag = helperNotes.findFirst(cltTag)) {
726  if (csd) {
727  csd->notes()->remove(cltTag);
728  csd->notes()->add(cltTag, connTag);
729  }
730  }
731  request.notes()->replaceOrAdd(&helperNotes);
732 }
733 
734 void
736 {
738 
740  return;
741 
743  if (port) {
744  myportname = port->name;
745  flags.ignoreCc = port->ignore_cc;
746  }
747 
748  if (auto clientConnection = clientConnectionManager->clientConnection) {
749  client_addr = clientConnection->remote; // XXX: remove request->client_addr member.
750 #if FOLLOW_X_FORWARDED_FOR
751  // indirect client gets stored here because it is an HTTP header result (from X-Forwarded-For:)
752  // not details about the TCP connection itself
753  indirect_client_addr = clientConnection->remote;
754 #endif /* FOLLOW_X_FORWARDED_FOR */
755  my_addr = clientConnection->local;
756 
757  flags.intercepted = ((clientConnection->flags & COMM_INTERCEPTION) != 0);
758  flags.interceptTproxy = ((clientConnection->flags & COMM_TRANSPARENT) != 0 ) ;
759  const bool proxyProtocolPort = port ? port->flags.proxySurrogate : false;
760  if (flags.interceptTproxy && !proxyProtocolPort) {
762  ACLFilledChecklist *checklist = new ACLFilledChecklist(Config.accessList.spoof_client_ip, this, clientConnection->rfc931);
763  checklist->al = al;
764  checklist->syncAle(this, nullptr);
765  flags.spoofClientIp = checklist->fastCheck().allowed();
766  delete checklist;
767  } else
768  flags.spoofClientIp = true;
769  } else
770  flags.spoofClientIp = false;
771  }
772 }
773 
774 char *
776 {
778 }
779 
781 static const Ip::Address *
783 {
784  // FindListeningPortAddress() callers do not want INADDR_ANY addresses
785  return (ip && !ip->isAnyAddr()) ? ip : nullptr;
786 }
787 
789 static const Ip::Address *
791 {
792  return port ? FindListeningPortAddressInAddress(&port->s) : nullptr;
793 }
794 
796 static const Ip::Address *
798 {
799  return conn ? FindListeningPortAddressInAddress(&conn->local) : nullptr;
800 }
801 
802 const Ip::Address *
803 FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
804 {
805  // Check all sources of usable listening port information, giving
806  // HttpRequest and masterXaction a preference over ALE.
807 
808  const HttpRequest *request = callerRequest;
809  if (!request && ale)
810  request = ale->request;
811  if (!request)
812  return nullptr; // not enough information
813 
815  if (!ip && ale)
817 
818  // XXX: also handle PROXY protocol here when we have a flag to identify such request
819  if (ip || request->flags.interceptTproxy || request->flags.intercepted)
820  return ip;
821 
822  /* handle non-intercepted cases that were not handled above */
824  if (!ip && ale)
826  return ip; // may still be nil
827 }
828 
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
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:404
static const Ip::Address * FindListeningPortAddressInAddress(const Ip::Address *ip)
a helper for validating FindListeningPortAddress()-found address candidates
Definition: HttpRequest.cc:782
bool hasNoStore() const
Definition: HttpHdrCc.h:102
HierarchyLogEntry hier
Definition: HttpRequest.h:157
static const Ip::Address * FindListeningPortAddressInConn(const Comm::ConnectionPointer &conn)
a helper for handling Connection cases of FindListeningPortAddress()
Definition: HttpRequest.cc:797
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
AnyP::PortCfgPointer squidPort
the listening port which originated this transaction
Definition: MasterXaction.h:50
bool interceptTproxy
Set for requests handled by a "tproxy" port.
Definition: RequestFlags.h:66
char * login
Definition: CachePeer.h:171
err_type errType
Definition: HttpRequest.h:161
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:686
HttpHdrRange * range
Definition: HttpRequest.h:143
collects information about adaptations related to a master transaction
Definition: History.h:23
#define assert(EX)
Definition: assert.h:17
Ip::Address my_addr
Definition: HttpRequest.h:155
SBuf & authority(bool requirePort=false) const
Definition: Uri.cc:528
String extacl_log
Definition: HttpRequest.h:183
HttpRequest(const MasterXaction::Pointer &)
Definition: HttpRequest.cc:43
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &helperNotes)
Definition: HttpRequest.cc:721
HttpHdrCc * cache_control
Definition: Message.h:77
ParseState pstate
the current parsing state
Definition: Message.h:95
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
int hdr_sz
Definition: Message.h:82
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
void path(const char *p)
Definition: Uri.h:97
Definition: SBuf.h:86
char * domain
Forced domain.
Definition: CachePeer.h:184
const char * null_string
Ip::Address src_addr
HttpRequestMethod method
Definition: HttpRequest.h:114
int prefixLen() const
Definition: HttpRequest.cc:372
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void add(const SBuf &key, const SBuf &value)
Definition: Notes.cc:280
void error(char *format,...)
int IcapLogfileStatus
Definition: icap_log.cc:20
virtual void buffer()
Definition: store.cc:1649
representation of a class of Size-limit ACLs
Definition: AclSizeLimit.h:16
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
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
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
virtual void flush()
Definition: store.cc:1660
void clear()
Definition: SBuf.cc:178
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:546
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
#define COMM_INTERCEPTION
Definition: Connection.h:51
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
AnyP::ProtocolVersion http_ver
Definition: Message.h:73
#define xisspace(x)
Definition: xis.h:17
void replaceOrAdd(const NotePairs *src)
Definition: Notes.cc:368
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
int conn
the current server connection FD
Definition: Transport.cc:26
time_t ims
Definition: HttpRequest.h:145
bool hostVerified
Definition: RequestFlags.h:64
uint64_t consumedSize() const
Definition: BodyPipe.h:111
const SBuf storeId()
Definition: HttpRequest.cc:694
const char * findTrailingHTTPVersion(const char *uriAndHTTPVersion, const char *end)
Acl::Answer const & fastCheck()
Definition: Checklist.cc:336
static const Ip::Address * FindListeningPortAddressInPort(const AnyP::PortCfgPointer &port)
a helper for handling PortCfg cases of FindListeningPortAddress()
Definition: HttpRequest.cc:790
virtual void append(const char *buf, int size)=0
Appends a c-string to existing packed data.
#define w_space
void prepForDirect()
get ready to be sent directly to an origin server, excluding originserver
Definition: HttpRequest.cc:459
bool auth_no_keytab
Definition: CachePeer.h:119
int64_t rangeOffsetLimit
Definition: HttpRequest.h:260
char * urlCanonicalCleanWithoutRequest(const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme)
Definition: Uri.cc:579
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:735
SBuf & absolute() const
Definition: Uri.cc:546
String extacl_message
Definition: HttpRequest.h:185
int gopherCachable(const HttpRequest *req)
Definition: gopher.cc:294
NotePairs::Pointer notes()
Definition: HttpRequest.cc:713
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:705
void append(const HttpHeader *src)
Definition: HttpHeader.cc:237
unsigned int major
major version number
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
int64_t content_length
Definition: Message.h:84
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:506
int wait
msecs spent waiting for the lookup (if any) or -1 (if none)
Definition: LookupDetails.h:30
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:128
#define DBG_IMPORTANT
Definition: Debug.h:46
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:337
int parse(const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
Definition: HttpHeader.cc:376
void pack(Packable *p) const
Definition: HttpRequest.cc:347
bool allowed() const
Definition: Acl.h:143
bool auth_no_keytab
Definition: RequestFlags.h:30
NotePairs::Pointer notes()
void setScheme(const AnyP::ProtocolType &p, const char *str)
convert the URL scheme to that given
Definition: Uri.h:70
Ip::Address client_addr
Definition: HttpRequest.h:149
virtual bool inheritProperties(const Http::Message *)
Definition: HttpRequest.cc:216
bool chunked() const
whether message uses chunked Transfer-Encoding
Definition: HttpHeader.h:196
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
struct SquidConfig::@113 accessList
HttpRequest * request
bool parse(const HttpRequestMethod &, const SBuf &url)
Definition: Uri.cc:203
char * canonicalCleanUrl() const
Definition: HttpRequest.cc:775
bool parseHeader(Http1::Parser &hp)
Definition: HttpRequest.cc:672
std::vector< HttpHdrRangeSpec * > specs
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
Definition: Address.cc:184
Http::MethodType id() const
Definition: RequestMethod.h:76
static int port
Definition: ldap_backend.cc:69
static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:535
bool isAnyAddr() const
Definition: Address.cc:170
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:482
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
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:157
class AccessLogEntry::CacheDetails cache
const SBuf & image() const
collects information about ICAP processing related to an HTTP transaction
Definition: History.h:23
virtual void syncAle(HttpRequest *adaptedRequest, const char *logUri) const
assigns uninitialized adapted_request and url ALE components
Ip::Address local
Definition: Connection.h:141
HttpHeader header
Definition: Message.h:75
RequestFlags flags
Definition: HttpRequest.h:141
bool maybeCacheable()
Definition: HttpRequest.cc:556
int has(Http::HdrType id) const
Definition: HttpHeader.cc:980
bool parseFirstLine(const char *start, const char *end)
Definition: HttpRequest.cc:297
#define LOG_ENABLE
Definition: defines.h:99
#define COMM_TRANSPARENT
Definition: Connection.h:50
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:236
void clean()
Definition: HttpHeader.cc:189
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
Definition: CbcPointer.h:162
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Definition: HttpRequest.h:159
void HttpRequestMethodXXX(char const *)
bool intercepted
Definition: RequestFlags.h:62
int64_t getRangeOffsetLimit()
Definition: HttpRequest.cc:619
AclSizeLimit * rangeOffsetLimit
Definition: SquidConfig.h:457
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:803
AnyP::PortCfgPointer port
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
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
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
Comm::ConnectionPointer clientConnection
Definition: Server.h:97
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
struct CachePeer::@31 options
RequestFlags cloneAdaptationImmune() const
Definition: RequestFlags.cc:18
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
Definition: Message.h:98
virtual void hdrCacheInit()
Definition: Message.cc:286
virtual HttpRequest * clone() const
Definition: HttpRequest.cc:177
bool multipartRangeRequest() const
Definition: HttpRequest.cc:437
void clean()
Definition: String.cc:125
unsigned int minor
minor version number
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
Definition: StringConvert.h:17
struct ConnStateData::@40 pinning
AnyP::UriScheme const & getScheme() const
Definition: Uri.h:67
void clear()
Definition: Uri.h:52
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpRequest.cc:271
#define SQUIDSBUFPH
Definition: SBuf.h:31
acl_access * spoof_client_ip
Definition: SquidConfig.h:398
String myportname
Definition: HttpRequest.h:175
void init()
Definition: HttpRequest.cc:77
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:32
LogConfig TheConfig
Definition: Config.cc:15
size_type size() const
Definition: SquidString.h:72
char * peer_login
Definition: HttpRequest.h:164
Definition: forward.h:21
bool respMaybeCacheable() const
Ip::Address indirect_client_addr
Definition: HttpRequest.h:152
bool originserver
Definition: CachePeer.h:114
bool spoofClientIp
Definition: RequestFlags.h:70
time_t lastmod
Definition: HttpRequest.h:168
void remove(const char *key)
Definition: Notes.cc:286
void clean()
Definition: HttpRequest.cc:123
Comm::ConnectionPointer tcpClient
the client TCP connection which originated this transaction
Definition: MasterXaction.h:53
class SquidConfig Config
Definition: SquidConfig.cc:12
Message(http_hdr_owner_type)
Definition: Message.cc:23
const char * findFirst(const char *noteKey) const
Definition: Notes.cc:265
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:192
#define NULL
Definition: types.h:166
uint32_t sources
The message sources.
Definition: Message.h:100
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:557
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
char * host
Definition: CachePeer.h:37
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
HttpHdrRange * getRange() const
Definition: HttpHeader.cc:1241

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors