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  char save = *end;
333 
334  * (char *) end = '\0'; // temp terminate URI, XXX dangerous?
335 
336  const bool ret = url.parse(method, start);
337 
338  * (char *) end = save;
339 
340  return ret;
341 }
342 
343 /* swaps out request using httpRequestPack */
344 void
346 {
347  assert(e);
348  e->buffer();
349  pack(e);
350  e->flush();
351 }
352 
353 /* packs request-line and headers, appends <crlf> terminator */
354 void
356 {
357  assert(p);
358  /* pack request-line */
359  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
362  /* headers */
363  header.packInto(p);
364  /* trailer */
365  p->append("\r\n", 2);
366 }
367 
368 /*
369  * A wrapper for debugObj()
370  */
371 void
373 {
374  HttpRequest *request = static_cast<HttpRequest*>(obj);
375  request->pack(p);
376 }
377 
378 /* returns the length of request line + headers + crlf */
379 int
381 {
382  return method.image().length() + 1 +
383  url.path().length() + 1 +
384  4 + 1 + 3 + 2 +
385  header.len + 2;
386 }
387 
388 /* sync this routine when you update HttpRequest struct */
389 void
391 {
393 
394  assert(!range);
395  range = header.getRange();
396 }
397 
398 #if ICAP_CLIENT
401 {
402  if (!icapHistory_) {
403  if (Log::TheConfig.hasIcapToken || IcapLogfileStatus == LOG_ENABLE) {
405  debugs(93,4, HERE << "made " << icapHistory_ << " for " << this);
406  }
407  }
408 
409  return icapHistory_;
410 }
411 #endif
412 
413 #if USE_ADAPTATION
415 HttpRequest::adaptHistory(bool createIfNone) const
416 {
417  if (!adaptHistory_ && createIfNone) {
419  debugs(93,4, HERE << "made " << adaptHistory_ << " for " << this);
420  }
421 
422  return adaptHistory_;
423 }
424 
427 {
428  return HttpRequest::adaptHistory(Log::TheConfig.hasAdaptToken);
429 }
430 
431 void
433 {
434  if (!adaptHistory_) {
435  adaptHistory_ = them.adaptHistory_; // may be nil
436  } else {
437  // check that histories did not diverge
438  Must(!them.adaptHistory_ || them.adaptHistory_ == adaptHistory_);
439  }
440 }
441 
442 #endif
443 
444 bool
446 {
447  return (range && range->specs.size() > 1);
448 }
449 
450 bool
452 {
453  return body_pipe != NULL && body_pipe->consumedSize() > 0;
454 }
455 
456 void
458 {
459  // XXX: Saving two pointers to memory controlled by an independent object.
460  peer_login = peer.login;
461  peer_domain = peer.domain;
463  debugs(11, 4, this << " to " << peer.host << (!peer.options.originserver ? " proxy" : " origin"));
464 }
465 
466 void
468 {
469  peer_login = nullptr;
470  peer_domain = nullptr;
471  flags.auth_no_keytab = false;
472  debugs(11, 4, this);
473 }
474 
475 void
477 {
478  if (errType || errDetail)
479  debugs(11, 5, HERE << "old error details: " << errType << '/' << errDetail);
480  debugs(11, 5, HERE << "current error details: " << aType << '/' << aDetail);
481  // checking type and detail separately may cause inconsistency, but
482  // may result in more details available if they only become available later
483  if (!errType)
484  errType = aType;
485  if (!errDetail)
486  errDetail = aDetail;
487 }
488 
489 void
491 {
492  debugs(11, 7, HERE << "old error details: " << errType << '/' << errDetail);
493  errType = ERR_NONE;
495 }
496 
497 void
499 {
500  const SBuf tmp(full_uri ? effectiveRequestUri() : url.path());
501 
502  // form HTTP request-line
503  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
505  SQUIDSBUFPRINT(tmp),
507 }
508 
509 /*
510  * Indicate whether or not we would expect an entity-body
511  * along with this request
512  */
513 bool
514 HttpRequest::expectingBody(const HttpRequestMethod &, int64_t &theSize) const
515 {
516  bool expectBody = false;
517 
518  /*
519  * Note: Checks for message validity is in clientIsContentLengthValid().
520  * this just checks if a entity-body is expected based on HTTP message syntax
521  */
522  if (header.chunked()) {
523  expectBody = true;
524  theSize = -1;
525  } else if (content_length >= 0) {
526  expectBody = true;
527  theSize = content_length;
528  } else {
529  expectBody = false;
530  // theSize undefined
531  }
532 
533  return expectBody;
534 }
535 
536 /*
537  * Create a Request from a URL and METHOD.
538  *
539  * If the METHOD is CONNECT, then a host:port pair is looked for instead of a URL.
540  * If the request cannot be created cleanly, NULL is returned
541  */
542 HttpRequest *
544 {
545  std::unique_ptr<HttpRequest> req(new HttpRequest(mx));
546  if (req->url.parse(method, url)) {
547  req->method = method;
548  return req.release();
549  }
550  return nullptr;
551 }
552 
557 bool
559 {
560  // Intercepted request with Host: header which cannot be trusted.
561  // Because it failed verification, or someone bypassed the security tests
562  // we cannot cache the reponse for sharing between clients.
563  // TODO: update cache to store for particular clients only (going to same Host: and destination IP)
565  return false;
566 
567  switch (url.getScheme()) {
568  case AnyP::PROTO_HTTP:
569  case AnyP::PROTO_HTTPS:
570  if (!method.respMaybeCacheable())
571  return false;
572 
573  // RFC 7234 section 5.2.1.5:
574  // "cache MUST NOT store any part of either this request or any response to it"
575  //
576  // NP: refresh_pattern ignore-no-store only applies to response messages
577  // this test is handling request message CC header.
579  return false;
580  break;
581 
582  case AnyP::PROTO_GOPHER:
583  if (!gopherCachable(this))
584  return false;
585  break;
586 
588  return false;
589 
590  //case AnyP::PROTO_FTP:
591  default:
592  break;
593  }
594 
595  return true;
596 }
597 
598 bool
600 {
601  return flags.ims ||
604 }
605 
606 void
608 {
609  if (dns.wait >= 0) { // known delay
610  if (dnsWait >= 0) { // have recorded DNS wait before
611  debugs(78, 7, this << " " << dnsWait << " += " << dns);
612  dnsWait += dns.wait;
613  } else {
614  debugs(78, 7, this << " " << dns);
615  dnsWait = dns.wait;
616  }
617  }
618 }
619 
620 int64_t
622 {
623  /* -2 is the starting value of rangeOffsetLimit.
624  * If it is -2, that means we haven't checked it yet.
625  * Otherwise, return the current value */
626  if (rangeOffsetLimit != -2)
627  return rangeOffsetLimit;
628 
629  rangeOffsetLimit = 0; // default value for rangeOffsetLimit
630 
631  ACLFilledChecklist ch(NULL, this, NULL);
632  ch.src_addr = client_addr;
633  ch.my_addr = my_addr;
634 
635  for (AclSizeLimit *l = Config.rangeOffsetLimit; l; l = l -> next) {
636  /* if there is no ACL list or if the ACLs listed match use this limit value */
637  if (!l->aclList || ch.fastCheck(l->aclList).allowed()) {
638  rangeOffsetLimit = l->size; // may be -1
639  debugs(58, 4, rangeOffsetLimit);
640  break;
641  }
642  }
643 
644  return rangeOffsetLimit;
645 }
646 
647 void
648 HttpRequest::ignoreRange(const char *reason)
649 {
650  if (range) {
651  debugs(73, 3, static_cast<void*>(range) << " for " << reason);
652  delete range;
653  range = NULL;
654  }
655  // Some callers also reset isRanged but it may not be safe for all callers:
656  // isRanged is used to determine whether a weak ETag comparison is allowed,
657  // and that check should not ignore the Range header if it was present.
658  // TODO: Some callers also delete HDR_RANGE, HDR_REQUEST_RANGE. Should we?
659 }
660 
661 bool
663 {
664  // old clients do not support 1xx unless they sent Expect: 100-continue
665  // (we reject all other Http::HdrType::EXPECT values so just check for Http::HdrType::EXPECT)
667  return false;
668 
669  // others must support 1xx control messages
670  return true;
671 }
672 
673 bool
675 {
677  return Message::parseHeader(hp, clen);
678 }
679 
680 bool
681 HttpRequest::parseHeader(const char *buffer, const size_t size)
682 {
684  return header.parse(buffer, size, clen);
685 }
686 
689 {
691  return clientConnectionManager.get();
692  return NULL;
693 }
694 
695 const SBuf
697 {
698  if (store_id.size() != 0) {
699  debugs(73, 3, "sent back store_id: " << store_id);
700  return StringToSBuf(store_id);
701  }
702  debugs(73, 3, "sent back effectiveRequestUrl: " << effectiveRequestUri());
703  return effectiveRequestUri();
704 }
705 
706 const SBuf &
708 {
710  return url.authority(true); // host:port
711  return url.absolute();
712 }
713 
716 {
717  if (!theNotes)
718  theNotes = new NotePairs;
719  return theNotes;
720 }
721 
722 void
724 {
725  // Tag client connection if the helper responded with clt_conn_tag=tag.
726  const char *cltTag = "clt_conn_tag";
727  if (const char *connTag = helperNotes.findFirst(cltTag)) {
728  if (csd) {
729  csd->notes()->remove(cltTag);
730  csd->notes()->add(cltTag, connTag);
731  }
732  }
733  request.notes()->replaceOrAdd(&helperNotes);
734 }
735 
736 void
738 {
740 
742  return;
743 
745  if (port) {
746  myportname = port->name;
747  flags.ignoreCc = port->ignore_cc;
748  }
749 
750  if (auto clientConnection = clientConnectionManager->clientConnection) {
751  client_addr = clientConnection->remote; // XXX: remove request->client_addr member.
752 #if FOLLOW_X_FORWARDED_FOR
753  // indirect client gets stored here because it is an HTTP header result (from X-Forwarded-For:)
754  // not details about the TCP connection itself
755  indirect_client_addr = clientConnection->remote;
756 #endif /* FOLLOW_X_FORWARDED_FOR */
757  my_addr = clientConnection->local;
758 
759  flags.intercepted = ((clientConnection->flags & COMM_INTERCEPTION) != 0);
760  flags.interceptTproxy = ((clientConnection->flags & COMM_TRANSPARENT) != 0 ) ;
761  const bool proxyProtocolPort = port ? port->flags.proxySurrogate : false;
762  if (flags.interceptTproxy && !proxyProtocolPort) {
764  ACLFilledChecklist *checklist = new ACLFilledChecklist(Config.accessList.spoof_client_ip, this, clientConnection->rfc931);
765  checklist->al = al;
766  checklist->syncAle(this, nullptr);
767  flags.spoofClientIp = checklist->fastCheck().allowed();
768  delete checklist;
769  } else
770  flags.spoofClientIp = true;
771  } else
772  flags.spoofClientIp = false;
773  }
774 }
775 
776 char *
778 {
780 }
781 
783 static const Ip::Address *
785 {
786  // FindListeningPortAddress() callers do not want INADDR_ANY addresses
787  return (ip && !ip->isAnyAddr()) ? ip : nullptr;
788 }
789 
791 static const Ip::Address *
793 {
794  return port ? FindListeningPortAddressInAddress(&port->s) : nullptr;
795 }
796 
798 static const Ip::Address *
800 {
801  return conn ? FindListeningPortAddressInAddress(&conn->local) : nullptr;
802 }
803 
804 const Ip::Address *
805 FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
806 {
807  // Check all sources of usable listening port information, giving
808  // HttpRequest and masterXaction a preference over ALE.
809 
810  const HttpRequest *request = callerRequest;
811  if (!request && ale)
812  request = ale->request;
813  if (!request)
814  return nullptr; // not enough information
815 
817  if (!ip && ale)
819 
820  // XXX: also handle PROXY protocol here when we have a flag to identify such request
821  if (ip || request->flags.interceptTproxy || request->flags.intercepted)
822  return ip;
823 
824  /* handle non-intercepted cases that were not handled above */
826  if (!ip && ale)
828  return ip; // may still be nil
829 }
830 
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
Definition: HttpRequest.h:236
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:607
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:784
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:799
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:688
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:503
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:723
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:93
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:380
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:1641
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:426
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:415
encapsulates DNS lookup results
Definition: LookupDetails.h:20
virtual void flush()
Definition: store.cc:1652
void clear()
Definition: SBuf.cc:178
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:69
#define COMM_INTERCEPTION
Definition: Connection.h:49
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:457
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:696
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:792
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:467
bool auth_no_keytab
Definition: CachePeer.h:119
int64_t rangeOffsetLimit
Definition: HttpRequest.h:257
char * urlCanonicalCleanWithoutRequest(const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme)
Definition: Uri.cc:551
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:737
SBuf & absolute() const
Definition: Uri.cc:521
String extacl_message
Definition: HttpRequest.h:185
int gopherCachable(const HttpRequest *req)
Definition: gopher.cc:294
NotePairs::Pointer notes()
Definition: HttpRequest.cc:715
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:707
void append(const HttpHeader *src)
Definition: HttpHeader.cc:235
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:432
int64_t content_length
Definition: Message.h:84
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:514
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:124
#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:345
int parse(const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
Definition: HttpHeader.cc:370
void pack(Packable *p) const
Definition: HttpRequest.cc:355
bool allowed() const
Definition: Acl.h:143
bool auth_no_keytab
Definition: RequestFlags.h:30
NotePairs::Pointer notes()
bool parse(const HttpRequestMethod &, const char *url)
Definition: Uri.cc:225
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:192
bool bodyNibbled() const
Definition: HttpRequest.cc:451
char * peer_host
Definition: HttpRequest.h:166
virtual void packFirstLineInto(Packable *p, bool full_uri) const
Definition: HttpRequest.cc:498
String tag
Definition: HttpRequest.h:177
common parts of HttpRequest and HttpReply
Definition: Message.h:25
NotePairs::Pointer theNotes
Definition: HttpRequest.h:261
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:230
struct SquidConfig::@113 accessList
HttpRequest * request
char * canonicalCleanUrl() const
Definition: HttpRequest.cc:777
bool parseHeader(Http1::Parser &hp)
Definition: HttpRequest.cc:674
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:73
static int port
Definition: ldap_backend.cc:69
bool isAnyAddr() const
Definition: Address.cc:170
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:490
static HttpRequest * FromUrl(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:543
static void httpRequestPack(void *obj, Packable *p)
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:648
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:153
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:135
HttpHeader header
Definition: Message.h:75
RequestFlags flags
Definition: HttpRequest.h:141
bool maybeCacheable()
Definition: HttpRequest.cc:558
int has(Http::HdrType id) const
Definition: HttpHeader.cc:977
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:48
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:233
void clean()
Definition: HttpHeader.cc:187
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:621
AclSizeLimit * rangeOffsetLimit
Definition: SquidConfig.h:457
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:805
AnyP::PortCfgPointer port
void detailError(err_type aType, int aDetail)
sets error detail if no earlier detail was available
Definition: HttpRequest.cc:476
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:599
ProtocolType
Definition: ProtocolType.h:22
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:445
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:554
virtual void hdrCacheInit()
Definition: HttpRequest.cc:390
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:662
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:400
HttpHdrRange * getRange() const
Definition: HttpHeader.cc:1238

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors