HttpRequest.cc
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2021 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 "error/Detail.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) :
52  Http::Message(hoRequest),
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  error.clear();
95  peer_login = NULL; // not allocated/deallocated by this class
96  peer_domain = NULL; // not allocated/deallocated by this class
97  peer_host = NULL;
98  vary_headers = SBuf();
100  tag = null_string;
101 #if USE_AUTH
104 #endif
108 #if FOLLOW_X_FORWARDED_FOR
110 #endif /* FOLLOW_X_FORWARDED_FOR */
111 #if USE_ADAPTATION
113 #endif
114 #if ICAP_CLIENT
115  icapHistory_ = NULL;
116 #endif
117  rangeOffsetLimit = -2; //a value of -2 means not checked yet
118  forcedBodyContinuation = false;
119 }
120 
121 void
123 {
124  // we used to assert that the pipe is NULL, but now the request only
125  // points to a pipe that is owned and initiated by another object.
126  body_pipe = NULL;
127 #if USE_AUTH
129 #endif
131  url.clear();
132 
133  header.clean();
134 
135  if (cache_control) {
136  delete cache_control;
138  }
139 
140  if (range) {
141  delete range;
142  range = NULL;
143  }
144 
145  myportname.clean();
146 
147  theNotes = nullptr;
148 
149  tag.clean();
150 #if USE_AUTH
151  extacl_user.clean();
153 #endif
154  extacl_log.clean();
155 
157 
158  etag.clean();
159 
160 #if USE_ADAPTATION
162 #endif
163 #if ICAP_CLIENT
164  icapHistory_ = NULL;
165 #endif
166 }
167 
168 void
170 {
171  clean();
172  init();
173 }
174 
175 HttpRequest *
177 {
179  copy->method = method;
180  // TODO: move common cloning clone to Msg::copyTo() or copy ctor
181  copy->header.append(&header);
182  copy->hdrCacheInit();
183  copy->hdr_sz = hdr_sz;
184  copy->http_ver = http_ver;
185  copy->pstate = pstate; // TODO: should we assert a specific state here?
186  copy->body_pipe = body_pipe;
187 
188  copy->url = url;
189 
190  // range handled in hdrCacheInit()
191  copy->ims = ims;
192  copy->imslen = imslen;
193  copy->hier = hier; // Is it safe to copy? Should we?
194 
195  copy->error = error;
196 
197  // XXX: what to do with copy->peer_login?
198 
199  copy->lastmod = lastmod;
200  copy->etag = etag;
201  copy->vary_headers = vary_headers;
202  // XXX: what to do with copy->peer_domain?
203 
204  copy->tag = tag;
205  copy->extacl_log = extacl_log;
207 
208  const bool inheritWorked = copy->inheritProperties(this);
209  assert(inheritWorked);
210 
211  return copy;
212 }
213 
214 bool
216 {
217  const HttpRequest* aReq = dynamic_cast<const HttpRequest*>(aMsg);
218  if (!aReq)
219  return false;
220 
221  client_addr = aReq->client_addr;
222 #if FOLLOW_X_FORWARDED_FOR
224 #endif
225  my_addr = aReq->my_addr;
226 
227  dnsWait = aReq->dnsWait;
228 
229 #if USE_ADAPTATION
230  adaptHistory_ = aReq->adaptHistory();
231 #endif
232 #if ICAP_CLIENT
233  icapHistory_ = aReq->icapHistory();
234 #endif
235 
236  // This may be too conservative for the 204 No Content case
237  // may eventually need cloneNullAdaptationImmune() for that.
239 
240  error = aReq->error;
241 #if USE_AUTH
243  extacl_user = aReq->extacl_user;
245 #endif
246 
247  myportname = aReq->myportname;
248 
250 
251  // main property is which connection the request was received on (if any)
253 
254  downloader = aReq->downloader;
255 
256  theNotes = aReq->theNotes;
257 
258  sources = aReq->sources;
259  return true;
260 }
261 
268 bool
269 HttpRequest::sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *scode)
270 {
271  // content is long enough to possibly hold a reply
272  // 2 being magic size of a 1-byte request method plus space delimiter
273  if (hdr_len < 2) {
274  // this is only a real error if the headers apparently complete.
275  if (hdr_len > 0) {
276  debugs(58, 3, HERE << "Too large request header (" << hdr_len << " bytes)");
277  *scode = Http::scInvalidHeader;
278  }
279  return false;
280  }
281 
282  /* See if the request buffer starts with a non-whitespace HTTP request 'method'. */
284  m.HttpRequestMethodXXX(buf);
285  if (m == Http::METHOD_NONE) {
286  debugs(73, 3, "HttpRequest::sanityCheckStartLine: did not find HTTP request method");
287  *scode = Http::scInvalidHeader;
288  return false;
289  }
290 
291  return true;
292 }
293 
294 bool
295 HttpRequest::parseFirstLine(const char *start, const char *end)
296 {
298 
299  if (method == Http::METHOD_NONE)
300  return false;
301 
302  // XXX: performance regression, strcspn() over the method bytes a second time.
303  // cheaper than allocate+copy+deallocate cycle to SBuf convert a piece of start.
304  const char *t = start + strcspn(start, w_space);
305 
306  start = t + strspn(t, w_space); // skip w_space after method
307 
308  const char *ver = findTrailingHTTPVersion(start, end);
309 
310  if (ver) {
311  end = ver - 1;
312 
313  while (xisspace(*end)) // find prev non-space
314  --end;
315 
316  ++end; // back to space
317 
318  if (2 != sscanf(ver + 5, "%d.%d", &http_ver.major, &http_ver.minor)) {
319  debugs(73, DBG_IMPORTANT, "parseRequestLine: Invalid HTTP identifier.");
320  return false;
321  }
322  } else {
323  http_ver.major = 0;
324  http_ver.minor = 9;
325  }
326 
327  if (end < start) // missing URI
328  return false;
329 
330  return url.parse(method, SBuf(start, size_t(end-start)));
331 }
332 
333 /* swaps out request using httpRequestPack */
334 void
336 {
337  assert(e);
338  e->buffer();
339  pack(e);
340  e->flush();
341 }
342 
343 /* packs request-line and headers, appends <crlf> terminator */
344 void
346 {
347  assert(p);
348  /* pack request-line */
349  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
352  /* headers */
353  header.packInto(p);
354  /* trailer */
355  p->append("\r\n", 2);
356 }
357 
358 /*
359  * A wrapper for debugObj()
360  */
361 void
362 httpRequestPack(void *obj, Packable *p)
363 {
364  HttpRequest *request = static_cast<HttpRequest*>(obj);
365  request->pack(p);
366 }
367 
368 /* returns the length of request line + headers + crlf */
369 int
371 {
372  return method.image().length() + 1 +
373  url.path().length() + 1 +
374  4 + 1 + 3 + 2 +
375  header.len + 2;
376 }
377 
378 /* sync this routine when you update HttpRequest struct */
379 void
381 {
383 
384  assert(!range);
385  range = header.getRange();
386 }
387 
388 #if ICAP_CLIENT
391 {
392  if (!icapHistory_) {
393  if (Log::TheConfig.hasIcapToken || IcapLogfileStatus == LOG_ENABLE) {
395  debugs(93,4, HERE << "made " << icapHistory_ << " for " << this);
396  }
397  }
398 
399  return icapHistory_;
400 }
401 #endif
402 
403 #if USE_ADAPTATION
405 HttpRequest::adaptHistory(bool createIfNone) const
406 {
407  if (!adaptHistory_ && createIfNone) {
409  debugs(93,4, HERE << "made " << adaptHistory_ << " for " << this);
410  }
411 
412  return adaptHistory_;
413 }
414 
417 {
418  return HttpRequest::adaptHistory(Log::TheConfig.hasAdaptToken);
419 }
420 
421 void
423 {
424  if (!adaptHistory_) {
425  adaptHistory_ = them.adaptHistory_; // may be nil
426  } else {
427  // check that histories did not diverge
428  Must(!them.adaptHistory_ || them.adaptHistory_ == adaptHistory_);
429  }
430 }
431 
432 #endif
433 
434 bool
436 {
437  return (range && range->specs.size() > 1);
438 }
439 
440 bool
442 {
443  return body_pipe != NULL && body_pipe->consumedSize() > 0;
444 }
445 
446 void
448 {
449  // XXX: Saving two pointers to memory controlled by an independent object.
450  peer_login = peer.login;
451  peer_domain = peer.domain;
453  debugs(11, 4, this << " to " << peer.host << (!peer.options.originserver ? " proxy" : " origin"));
454 }
455 
456 void
458 {
459  peer_login = nullptr;
460  peer_domain = nullptr;
461  flags.auth_no_keytab = false;
462  debugs(11, 4, this);
463 }
464 
465 void
467 {
468  debugs(11, 7, "old: " << error);
469  error.clear();
470 }
471 
472 void
473 HttpRequest::packFirstLineInto(Packable * p, bool full_uri) const
474 {
475  const SBuf tmp(full_uri ? effectiveRequestUri() : url.path());
476 
477  // form HTTP request-line
478  p->appendf(SQUIDSBUFPH " " SQUIDSBUFPH " HTTP/%d.%d\r\n",
480  SQUIDSBUFPRINT(tmp),
482 }
483 
484 /*
485  * Indicate whether or not we would expect an entity-body
486  * along with this request
487  */
488 bool
489 HttpRequest::expectingBody(const HttpRequestMethod &, int64_t &theSize) const
490 {
491  bool expectBody = false;
492 
493  /*
494  * Note: Checks for message validity is in clientIsContentLengthValid().
495  * this just checks if a entity-body is expected based on HTTP message syntax
496  */
497  if (header.chunked()) {
498  expectBody = true;
499  theSize = -1;
500  } else if (content_length >= 0) {
501  expectBody = true;
502  theSize = content_length;
503  } else {
504  expectBody = false;
505  // theSize undefined
506  }
507 
508  return expectBody;
509 }
510 
511 /*
512  * Create a Request from a URL and METHOD.
513  *
514  * If the METHOD is CONNECT, then a host:port pair is looked for instead of a URL.
515  * If the request cannot be created cleanly, NULL is returned
516  */
517 HttpRequest *
519 {
520  std::unique_ptr<HttpRequest> req(new HttpRequest(mx));
521  if (req->url.parse(method, url)) {
522  req->method = method;
523  return req.release();
524  }
525  return nullptr;
526 }
527 
528 HttpRequest *
529 HttpRequest::FromUrlXXX(const char * url, const MasterXaction::Pointer &mx, const HttpRequestMethod& method)
530 {
531  return FromUrl(SBuf(url), mx, method);
532 }
533 
538 bool
540 {
541  // Intercepted request with Host: header which cannot be trusted.
542  // Because it failed verification, or someone bypassed the security tests
543  // we cannot cache the response for sharing between clients.
544  // TODO: update cache to store for particular clients only (going to same Host: and destination IP)
546  return false;
547 
548  switch (url.getScheme()) {
549  case AnyP::PROTO_HTTP:
550  case AnyP::PROTO_HTTPS:
551  if (!method.respMaybeCacheable())
552  return false;
553 
554  // RFC 7234 section 5.2.1.5:
555  // "cache MUST NOT store any part of either this request or any response to it"
556  //
557  // NP: refresh_pattern ignore-no-store only applies to response messages
558  // this test is handling request message CC header.
560  return false;
561  break;
562 
563  case AnyP::PROTO_GOPHER:
564  if (!gopherCachable(this))
565  return false;
566  break;
567 
569  return false;
570 
571  //case AnyP::PROTO_FTP:
572  default:
573  break;
574  }
575 
576  return true;
577 }
578 
579 bool
581 {
582  return flags.ims ||
585 }
586 
587 void
589 {
590  if (dns.wait >= 0) { // known delay
591  if (dnsWait >= 0) { // have recorded DNS wait before
592  debugs(78, 7, this << " " << dnsWait << " += " << dns);
593  dnsWait += dns.wait;
594  } else {
595  debugs(78, 7, this << " " << dns);
596  dnsWait = dns.wait;
597  }
598  }
599 }
600 
601 int64_t
603 {
604  /* -2 is the starting value of rangeOffsetLimit.
605  * If it is -2, that means we haven't checked it yet.
606  * Otherwise, return the current value */
607  if (rangeOffsetLimit != -2)
608  return rangeOffsetLimit;
609 
610  rangeOffsetLimit = 0; // default value for rangeOffsetLimit
611 
612  ACLFilledChecklist ch(NULL, this, NULL);
613  ch.src_addr = client_addr;
614  ch.my_addr = my_addr;
615 
616  for (AclSizeLimit *l = Config.rangeOffsetLimit; l; l = l -> next) {
617  /* if there is no ACL list or if the ACLs listed match use this limit value */
618  if (!l->aclList || ch.fastCheck(l->aclList).allowed()) {
619  rangeOffsetLimit = l->size; // may be -1
620  debugs(58, 4, rangeOffsetLimit);
621  break;
622  }
623  }
624 
625  return rangeOffsetLimit;
626 }
627 
628 void
629 HttpRequest::ignoreRange(const char *reason)
630 {
631  if (range) {
632  debugs(73, 3, static_cast<void*>(range) << " for " << reason);
633  delete range;
634  range = NULL;
635  }
636  // Some callers also reset isRanged but it may not be safe for all callers:
637  // isRanged is used to determine whether a weak ETag comparison is allowed,
638  // and that check should not ignore the Range header if it was present.
639  // TODO: Some callers also delete HDR_RANGE, HDR_REQUEST_RANGE. Should we?
640 }
641 
642 bool
644 {
645  // old clients do not support 1xx unless they sent Expect: 100-continue
646  // (we reject all other Http::HdrType::EXPECT values so just check for Http::HdrType::EXPECT)
648  return false;
649 
650  // others must support 1xx control messages
651  return true;
652 }
653 
656 {
657  // RFC 7230 section 3.3.1:
658  // "
659  // A server that receives a request message with a transfer coding it
660  // does not understand SHOULD respond with 501 (Not Implemented).
661  // "
662  if (header.unsupportedTe())
663  return Http::scNotImplemented;
664 
665  // RFC 7230 section 3.3.3 #3 paragraph 3:
666  // Transfer-Encoding overrides Content-Length
667  if (header.chunked())
668  return Http::scNone;
669 
670  // RFC 7230 Section 3.3.3 #4:
671  // conflicting Content-Length(s) mean a message framing error
673  return Http::scBadRequest;
674 
675  // HTTP/1.0 requirements differ from HTTP/1.1
676  if (http_ver <= Http::ProtocolVersion(1,0)) {
677  const auto m = method.id();
678 
679  // RFC 1945 section 8.3:
680  // "
681  // A valid Content-Length is required on all HTTP/1.0 POST requests.
682  // "
683  // RFC 1945 Appendix D.1.1:
684  // "
685  // The fundamental difference between the POST and PUT requests is
686  // reflected in the different meaning of the Request-URI.
687  // "
688  if (m == Http::METHOD_POST || m == Http::METHOD_PUT)
690 
691  // RFC 1945 section 7.2:
692  // "
693  // An entity body is included with a request message only when the
694  // request method calls for one.
695  // "
696  // section 8.1-2: GET and HEAD do not define ('call for') an entity
697  if (m == Http::METHOD_GET || m == Http::METHOD_HEAD)
699  // appendix D1.1.2-4: DELETE, LINK, UNLINK do not define ('call for') an entity
702 
703  // other methods are not defined in RFC 1945
704  // assume they support an (optional) entity
705  return Http::scNone;
706  }
707 
708  // RFC 7230 section 3.3
709  // "
710  // The presence of a message body in a request is signaled by a
711  // Content-Length or Transfer-Encoding header field. Request message
712  // framing is independent of method semantics, even if the method does
713  // not define any use for a message body.
714  // "
715  return Http::scNone;
716 }
717 
718 bool
720 {
722  return Message::parseHeader(hp, clen);
723 }
724 
725 bool
726 HttpRequest::parseHeader(const char *buffer, const size_t size)
727 {
729  return header.parse(buffer, size, clen);
730 }
731 
734 {
736  return clientConnectionManager.get();
737  return NULL;
738 }
739 
740 const SBuf
742 {
743  if (store_id.size() != 0) {
744  debugs(73, 3, "sent back store_id: " << store_id);
745  return StringToSBuf(store_id);
746  }
747  debugs(73, 3, "sent back effectiveRequestUrl: " << effectiveRequestUri());
748  return effectiveRequestUri();
749 }
750 
751 const SBuf &
753 {
755  return url.authority(true); // host:port
756  return url.absolute();
757 }
758 
761 {
762  if (!theNotes)
763  theNotes = new NotePairs;
764  return theNotes;
765 }
766 
767 void
769 {
770  // Tag client connection if the helper responded with clt_conn_tag=tag.
771  const char *cltTag = "clt_conn_tag";
772  if (const char *connTag = helperNotes.findFirst(cltTag)) {
773  if (csd) {
774  csd->notes()->remove(cltTag);
775  csd->notes()->add(cltTag, connTag);
776  }
777  }
778  request.notes()->replaceOrAdd(&helperNotes);
779 }
780 
781 void
783 {
785 
787  return;
788 
790  if (port) {
791  myportname = port->name;
792  flags.ignoreCc = port->ignore_cc;
793  }
794 
795  if (auto clientConnection = clientConnectionManager->clientConnection) {
796  client_addr = clientConnection->remote; // XXX: remove request->client_addr member.
797 #if FOLLOW_X_FORWARDED_FOR
798  // indirect client gets stored here because it is an HTTP header result (from X-Forwarded-For:)
799  // not details about the TCP connection itself
800  indirect_client_addr = clientConnection->remote;
801 #endif /* FOLLOW_X_FORWARDED_FOR */
802  my_addr = clientConnection->local;
803 
804  flags.intercepted = ((clientConnection->flags & COMM_INTERCEPTION) != 0);
805  flags.interceptTproxy = ((clientConnection->flags & COMM_TRANSPARENT) != 0 ) ;
806  const bool proxyProtocolPort = port ? port->flags.proxySurrogate : false;
807  if (flags.interceptTproxy && !proxyProtocolPort) {
809  ACLFilledChecklist *checklist = new ACLFilledChecklist(Config.accessList.spoof_client_ip, this, clientConnection->rfc931);
810  checklist->al = al;
811  checklist->syncAle(this, nullptr);
812  flags.spoofClientIp = checklist->fastCheck().allowed();
813  delete checklist;
814  } else
815  flags.spoofClientIp = true;
816  } else
817  flags.spoofClientIp = false;
818  }
819 }
820 
821 char *
823 {
825 }
826 
828 static const Ip::Address *
830 {
831  // FindListeningPortAddress() callers do not want INADDR_ANY addresses
832  return (ip && !ip->isAnyAddr()) ? ip : nullptr;
833 }
834 
836 static const Ip::Address *
838 {
839  return port ? FindListeningPortAddressInAddress(&port->s) : nullptr;
840 }
841 
843 static const Ip::Address *
845 {
846  return conn ? FindListeningPortAddressInAddress(&conn->local) : nullptr;
847 }
848 
849 const Ip::Address *
850 FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
851 {
852  // Check all sources of usable listening port information, giving
853  // HttpRequest and masterXaction a preference over ALE.
854 
855  const HttpRequest *request = callerRequest;
856  if (!request && ale)
857  request = ale->request;
858  if (!request)
859  return nullptr; // not enough information
860 
861  const Ip::Address *ip = FindListeningPortAddressInPort(request->masterXaction->squidPort);
862  if (!ip && ale)
864 
865  // XXX: also handle PROXY protocol here when we have a flag to identify such request
866  if (ip || request->flags.interceptTproxy || request->flags.intercepted)
867  return ip;
868 
869  /* handle non-intercepted cases that were not handled above */
870  ip = FindListeningPortAddressInConn(request->masterXaction->tcpClient);
871  if (!ip && ale)
873  return ip; // may still be nil
874 }
875 
int hdr_sz
Definition: Message.h:82
bool bodyNibbled() const
Definition: HttpRequest.cc:441
void append(const HttpHeader *src)
Definition: HttpHeader.cc:239
Cbc * get() const
a temporary valid raw Cbc pointer or NULL
Definition: CbcPointer.h:162
virtual bool inheritProperties(const Http::Message *)
Definition: HttpRequest.cc:215
virtual void buffer()
Definition: store.cc:1627
char * peer_host
Definition: HttpRequest.h:165
static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:518
const char * findTrailingHTTPVersion(const char *uriAndHTTPVersion, const char *end)
unsigned int major
major version number
HttpHdrRange * getRange() const
Definition: HttpHeader.cc:1267
bool conflictingContentLength() const
Definition: HttpHeader.h:113
virtual void packFirstLineInto(Packable *p, bool full_uri) const
Definition: HttpRequest.cc:473
AnyP::ProtocolVersion http_ver
Definition: Message.h:73
bool unsupportedTe() const
whether message used an unsupported and/or invalid Transfer-Encoding
Definition: HttpHeader.h:168
void ignoreRange(const char *reason)
forgets about the cached Range header (for a reason)
Definition: HttpRequest.cc:629
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
Definition: Packable.h:61
virtual void reset()
Definition: HttpRequest.cc:169
@ METHOD_HEAD
Definition: MethodType.h:28
AnyP::Uri url
the request URI
Definition: HttpRequest.h:115
common parts of HttpRequest and HttpReply
Definition: Message.h:26
bool interceptTproxy
Set for requests handled by a "tproxy" port.
Definition: RequestFlags.h:66
static const Ip::Address * FindListeningPortAddressInAddress(const Ip::Address *ip)
a helper for validating FindListeningPortAddress()-found address candidates
Definition: HttpRequest.cc:829
Cbc * valid() const
was set and is valid
Definition: CbcPointer.h:41
@ METHOD_UNLINK
Definition: MethodType.h:36
BodyPipe::Pointer body_pipe
optional pipeline to receive message body
Definition: Message.h:98
char * canonicalCleanUrl() const
Definition: HttpRequest.cc:822
bool parseHeader(Http1::Parser &hp)
Definition: HttpRequest.cc:719
const char * findFirst(const char *noteKey) const
Definition: Notes.cc:297
bool spoofClientIp
Definition: RequestFlags.h:70
Ip::Address src_addr
@ scBadRequest
Definition: StatusCode.h:44
@ scNone
Definition: StatusCode.h:21
HttpHeader header
Definition: Message.h:75
virtual void flush()
Definition: store.cc:1638
struct CachePeer::@30 options
RequestFlags flags
Definition: HttpRequest.h:141
struct ConnStateData::@39 pinning
void clearError()
clear error details, useful for retries/repeats
Definition: HttpRequest.cc:466
@ scLengthRequired
Definition: StatusCode.h:55
representation of a class of Size-limit ACLs
Definition: AclSizeLimit.h:17
bool isAnyAddr() const
Definition: Address.cc:170
int64_t getRangeOffsetLimit()
Definition: HttpRequest.cc:602
AclSizeLimit * rangeOffsetLimit
Definition: SquidConfig.h:465
CbcPointer< Downloader > downloader
The Downloader object which initiated the HTTP request if any.
Definition: HttpRequest.h:235
unsigned int minor
minor version number
bool pinned
this connection was pinned
Definition: client_side.h:147
char * login
Definition: CachePeer.h:174
int parse(const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
Definition: HttpHeader.cc:381
bool parse(const HttpRequestMethod &, const SBuf &url)
Definition: Uri.cc:253
Definition: SBuf.h:87
virtual void append(const char *buf, int size)=0
Appends a c-string to existing packed data.
void httpRequestPack(void *obj, Packable *p)
Definition: HttpRequest.cc:362
bool hostVerified
Definition: RequestFlags.h:64
LogConfig TheConfig
Definition: Config.cc:15
bool maybeCacheable()
Definition: HttpRequest.cc:539
#define LOG_ENABLE
Definition: defines.h:62
Auth::UserRequest::Pointer auth_user_request
Definition: HttpRequest.h:127
bool parseFirstLine(const char *start, const char *end)
Definition: HttpRequest.cc:295
AccessLogEntry::Pointer al
info for the future access.log, and external ACL
const SBuf & image() const
Acl::Answer const & fastCheck()
Definition: Checklist.cc:336
int dnsWait
sum of DNS lookup delays in milliseconds, for dt
Definition: HttpRequest.h:159
StatusCode
Definition: StatusCode.h:20
Definition: forward.h:22
bool multipartRangeRequest() const
Definition: HttpRequest.cc:435
bool respMaybeCacheable() const
bool auth_no_keytab
Definition: RequestFlags.h:30
#define DBG_IMPORTANT
Definition: Debug.h:41
#define w_space
bool conditional() const
has at least one recognized If-* header
Definition: HttpRequest.cc:580
String extacl_user
Definition: HttpRequest.h:178
Adaptation::History::Pointer adaptHistory_
per-HTTP transaction info
Definition: HttpRequest.h:119
static int port
Definition: ldap_backend.cc:69
Error error
the first transaction problem encountered (or falsy)
Definition: HttpRequest.h:161
void clear()
Definition: SBuf.cc:175
bool auth_no_keytab
Definition: CachePeer.h:122
AnyP::UriScheme const & getScheme() const
Definition: Uri.h:67
bool chunked() const
Definition: HttpHeader.h:165
char * domain
Forced domain.
Definition: CachePeer.h:187
String myportname
Definition: HttpRequest.h:174
void init()
Definition: HttpRequest.cc:77
#define COMM_INTERCEPTION
Definition: Connection.h:51
virtual HttpRequest * clone() const
Definition: HttpRequest.cc:176
ProtocolType
Definition: ProtocolType.h:23
HttpRequest * request
static const Ip::Address * FindListeningPortAddressInPort(const AnyP::PortCfgPointer &port)
a helper for handling PortCfg cases of FindListeningPortAddress()
Definition: HttpRequest.cc:837
#define COMM_TRANSPARENT
Definition: Connection.h:50
time_t lastmod
Definition: HttpRequest.h:167
virtual void hdrCacheInit()
Definition: Message.cc:279
Http::MethodType id() const
Definition: RequestMethod.h:70
String etag
A strong etag of the cached entry. Used for refreshing that entry.
Definition: HttpRequest.h:191
void clean()
Definition: HttpRequest.cc:122
void clear()
Definition: Uri.h:52
int size
Definition: ModDevPoll.cc:77
virtual bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error)
Definition: HttpRequest.cc:269
#define NULL
Definition: types.h:166
#define SQUIDSBUFPRINT(s)
Definition: SBuf.h:32
#define debugs(SECTION, LEVEL, CONTENT)
Definition: Debug.h:123
@ scNotImplemented
Definition: StatusCode.h:72
void recordLookup(const Dns::LookupDetails &detail)
Definition: HttpRequest.cc:588
int wait
msecs spent waiting for the lookup (if any) or -1 (if none)
Definition: LookupDetails.h:30
Ip::Address indirect_client_addr
Definition: HttpRequest.h:152
char * peer_login
Definition: HttpRequest.h:163
@ METHOD_DELETE
Definition: MethodType.h:32
ConnStateData * pinnedConnection()
Definition: HttpRequest.cc:733
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
Definition: StringConvert.h:17
int gopherCachable(const HttpRequest *req)
Definition: gopher.cc:289
virtual void hdrCacheInit()
Definition: HttpRequest.cc:380
bool canHandle1xx() const
whether the client is likely to be able to handle a 1xx reply
Definition: HttpRequest.cc:643
std::ostream & HERE(std::ostream &s)
Definition: Debug.h:152
@ METHOD_CONNECT
Definition: MethodType.h:29
Comm::ConnectionPointer tcpClient
TCP/IP level details about the client connection.
static const Ip::Address * FindListeningPortAddressInConn(const Comm::ConnectionPointer &conn)
a helper for handling Connection cases of FindListeningPortAddress()
Definition: HttpRequest.cc:844
char * peer_domain
Definition: HttpRequest.h:172
Adaptation::Icap::History::Pointer icapHistory() const
Returns possibly nil history, creating it if icap logging is enabled.
Definition: HttpRequest.cc:390
acl_access * spoof_client_ip
Definition: SquidConfig.h:406
HttpRequest(const MasterXaction::Pointer &)
Definition: HttpRequest.cc:43
NotePairs::Pointer notes()
MasterXaction::Pointer masterXaction
the master transaction this request belongs to. Never nil.
Definition: HttpRequest.h:238
struct SquidConfig::@112 accessList
int conn
the current server connection FD
Definition: Transport.cc:26
#define assert(EX)
Definition: assert.h:19
bool intercepted
Definition: RequestFlags.h:62
HttpHdrCc * cache_control
Definition: Message.h:77
class AccessLogEntry::CacheDetails cache
@ METHOD_POST
Definition: MethodType.h:26
HierarchyLogEntry hier
Definition: HttpRequest.h:157
virtual void syncAle(HttpRequest *adaptedRequest, const char *logUri) const
assigns uninitialized adapted_request and url ALE components
@ METHOD_PUT
Definition: MethodType.h:27
encapsulates DNS lookup results
Definition: LookupDetails.h:21
SBuf vary_headers
The variant second-stage cache key. Generated from Vary header pattern for this request.
Definition: HttpRequest.h:170
Ip::Address my_addr
Definition: HttpRequest.h:155
void HttpRequestMethodXXX(char const *)
@ PROTO_GOPHER
Definition: ProtocolType.h:30
Adaptation::Icap::History::Pointer icapHistory_
per-HTTP transaction info
Definition: HttpRequest.h:122
HttpHdrRange * range
Definition: HttpRequest.h:143
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:583
void initHTTP(const HttpRequestMethod &aMethod, AnyP::ProtocolType aProtocol, const char *schemeImage, const char *aUrlpath)
Definition: HttpRequest.cc:69
const char * null_string
int IcapLogfileStatus
Definition: icap_log.cc:20
SBuf & authority(bool requirePort=false) const
Definition: Uri.cc:565
Http::StatusCode checkEntityFraming() const
Definition: HttpRequest.cc:655
int prefixLen() const
Definition: HttpRequest.cc:370
size_type length() const
Returns the number of bytes stored in SBuf.
Definition: SBuf.h:408
String extacl_log
Definition: HttpRequest.h:182
Comm::ConnectionPointer clientConnection
Definition: Server.h:98
void setEmpty()
Fast reset of the stored content to what would be after default constructor.
Definition: Address.cc:184
int64_t content_length
Definition: Message.h:84
uint32_t sources
The message sources.
Definition: Message.h:100
Adaptation::History::Pointer adaptHistory(bool createIfNone=false) const
Returns possibly nil history, creating it if requested.
Definition: HttpRequest.cc:405
const Ip::Address * FindListeningPortAddress(const HttpRequest *callerRequest, const AccessLogEntry *ale)
Definition: HttpRequest.cc:850
Adaptation::History::Pointer adaptLogHistory() const
Returns possibly nil history, creating it if adapt. logging is enabled.
Definition: HttpRequest.cc:416
@ PROTO_CACHE_OBJECT
Definition: ProtocolType.h:32
@ PROTO_AUTHORITY_FORM
Definition: ProtocolType.h:42
SBuf & absolute() const
Definition: Uri.cc:583
@ PROTO_HTTPS
Definition: ProtocolType.h:27
HttpRequestMethod method
Definition: HttpRequest.h:114
void path(const char *p)
Definition: Uri.h:99
@ PROTO_HTTP
Definition: ProtocolType.h:25
char * host
Definition: CachePeer.h:40
std::vector< HttpHdrRangeSpec * > specs
ParseState pstate
the current parsing state
Definition: Message.h:95
bool allowed() const
Definition: Acl.h:143
void prepForPeering(const CachePeer &peer)
get ready to be sent to the given cache_peer, including originserver
Definition: HttpRequest.cc:447
collects information about ICAP processing related to an HTTP transaction
Definition: History.h:24
bool forcedBodyContinuation
whether we have responded with HTTP 100 or FTP 150 already
Definition: HttpRequest.h:194
int has(Http::HdrType id) const
Definition: HttpHeader.cc:1006
const SBuf storeId()
Definition: HttpRequest.cc:741
size_type size() const
Definition: SquidString.h:73
@ METHOD_NONE
Definition: MethodType.h:22
AnyP::PortCfgPointer port
static HttpRequest * FromUrlXXX(const char *url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
Definition: HttpRequest.cc:529
#define Must(condition)
Like assert() but throws an exception instead of aborting the process.
Definition: TextException.h:73
int64_t rangeOffsetLimit
Definition: HttpRequest.h:263
void manager(const CbcPointer< ConnStateData > &aMgr, const AccessLogEntryPointer &al)
associates the request with a from-client connection manager
Definition: HttpRequest.cc:782
void remove(const char *key)
Definition: Notes.cc:318
time_t ims
Definition: HttpRequest.h:145
void add(const SBuf &key, const SBuf &value)
Definition: Notes.cc:312
String extacl_message
Definition: HttpRequest.h:184
@ scInvalidHeader
Definition: StatusCode.h:86
char * urlCanonicalCleanWithoutRequest(const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme)
Definition: Uri.cc:619
collects information about adaptations related to a master transaction
Definition: History.h:24
void prepForDirect()
get ready to be sent directly to an origin server, excluding originserver
Definition: HttpRequest.cc:457
int port
port of pinned connection
Definition: client_side.h:146
#define xisspace(x)
Definition: xis.h:17
void swapOut(StoreEntry *e)
Definition: HttpRequest.cc:335
void setScheme(const AnyP::ProtocolType &p, const char *str)
convert the URL scheme to that given
Definition: Uri.h:70
@ METHOD_GET
Definition: MethodType.h:25
const SBuf & effectiveRequestUri() const
RFC 7230 section 5.5 - Effective Request URI.
Definition: HttpRequest.cc:752
NotePairs::Pointer notes()
Definition: HttpRequest.cc:760
Ip::Address client_addr
Definition: HttpRequest.h:149
bool hasNoStore() const
Definition: HttpHdrCc.h:102
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
void clear()
switch to the default "no error information" state
Definition: Error.h:33
String tag
Definition: HttpRequest.h:176
@ hoRequest
Definition: HttpHeader.h:36
RequestFlags cloneAdaptationImmune() const
Definition: RequestFlags.cc:18
void adaptHistoryImport(const HttpRequest &them)
Makes their history ours, throwing on conflicts.
Definition: HttpRequest.cc:422
virtual bool expectingBody(const HttpRequestMethod &unused, int64_t &) const
Definition: HttpRequest.cc:489
String extacl_passwd
Definition: HttpRequest.h:180
String store_id
Definition: HttpRequest.h:139
void clean()
Definition: HttpHeader.cc:190
uint64_t consumedSize() const
Definition: BodyPipe.h:111
bool originserver
Definition: CachePeer.h:117
@ METHOD_LINK
Definition: MethodType.h:35
NotePairs::Pointer theNotes
Definition: HttpRequest.h:267
#define SQUIDSBUFPH
Definition: SBuf.h:31
CbcPointer< ConnStateData > clientConnectionManager
Definition: HttpRequest.h:232
void pack(Packable *p) const
Definition: HttpRequest.cc:345
class SquidConfig Config
Definition: SquidConfig.cc:12
void UpdateRequestNotes(ConnStateData *csd, HttpRequest &request, NotePairs const &helperNotes)
Definition: HttpRequest.cc:768
void clean()
Definition: String.cc:125
AnyP::ProtocolVersion ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
HTTP version label information.
@ psReadyToParseStartLine
Definition: Message.h:88

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors