#include "squid.h"
#include "acl/FilledChecklist.h"
#include "acl/Gadgets.h"
#include "base/EnumIterator.h"
#include "client_side.h"
#include "client_side_request.h"
#include "comm/Connection.h"
#include "compat/strtoll.h"
#include "ConfigParser.h"
#include "fde.h"
#include "globals.h"
#include "http/RegisteredHeaders.h"
#include "http/Stream.h"
#include "HttpHdrContRange.h"
#include "HttpHeader.h"
#include "HttpHeaderTools.h"
#include "HttpRequest.h"
#include "MemBuf.h"
#include "sbuf/Stream.h"
#include "sbuf/StringConvert.h"
#include "SquidConfig.h"
#include "Store.h"
#include "StrList.h"
#include "ssl/support.h"
#include <algorithm>
#include <cerrno>
#include <string>
Go to the source code of this file.
Macros | |
#define | SHORT_PREFIX_SIZE 512 |
Functions | |
static void | httpHeaderPutStrvf (HttpHeader *hdr, Http::HdrType id, const char *fmt, va_list vargs) |
static void | httpHdrAdd (HttpHeader *heads, HttpRequest *request, const AccessLogEntryPointer &al, HeaderWithAclList &headersAdd) |
void | httpHeaderMaskInit (HttpHeaderMask *mask, int value) |
void | httpHeaderPutStrf (HttpHeader *hdr, Http::HdrType id, const char *fmt,...) |
void | httpHeaderAddContRange (HttpHeader *hdr, HttpHdrRangeSpec spec, int64_t ent_len) |
bool | httpHeaderHasConnDir (const HttpHeader *hdr, const SBuf &directive) |
const char * | getStringPrefix (const char *str, size_t sz) |
int | httpHeaderParseInt (const char *start, int *value) |
bool | httpHeaderParseOffset (const char *start, int64_t *value, char **endPtr) |
int | httpHeaderParseQuotedString (const char *start, const int len, String *val) |
SBuf | httpHeaderQuoteString (const char *raw) |
quotes string using RFC 7230 quoted-string rules More... | |
static int | httpHdrMangle (HttpHeaderEntry *e, HttpRequest *request, HeaderManglers *hms, const AccessLogEntryPointer &al) |
void | httpHdrMangleList (HttpHeader *l, HttpRequest *request, const AccessLogEntryPointer &al, req_or_rep_t req_or_rep) |
static void | header_mangler_clean (headerMangler &m) |
static void | header_mangler_dump_access (StoreEntry *entry, const char *option, const headerMangler &m, const char *name) |
static void | header_mangler_dump_replacement (StoreEntry *entry, const char *option, const headerMangler &m, const char *name) |
Macro Definition Documentation
◆ SHORT_PREFIX_SIZE
#define SHORT_PREFIX_SIZE 512 |
Function Documentation
◆ getStringPrefix()
const char * getStringPrefix | ( | const char * | str, |
size_t | sz | ||
) |
handy to printf prefixes of potentially very long buffers
Definition at line 110 of file HttpHeaderTools.cc.
References LOCAL_ARRAY, SHORT_PREFIX_SIZE, and xstrncpy().
Referenced by HttpHeaderEntry::parse(), and HttpHeader::parse().
◆ header_mangler_clean()
|
static |
Definition at line 373 of file HttpHeaderTools.cc.
References headerMangler::access_list, aclDestroyAccessList(), headerMangler::replacement, and safe_free.
Referenced by HeaderManglers::~HeaderManglers().
◆ header_mangler_dump_access()
|
static |
Definition at line 380 of file HttpHeaderTools.cc.
References headerMangler::access_list, dump_acl_access(), and storeAppendPrintf().
Referenced by HeaderManglers::dumpAccess().
◆ header_mangler_dump_replacement()
|
static |
Definition at line 390 of file HttpHeaderTools.cc.
References headerMangler::replacement, and storeAppendPrintf().
Referenced by HeaderManglers::dumpReplacement().
◆ httpHdrAdd()
|
static |
Definition at line 498 of file HttpHeaderTools.cc.
References HttpHeader::addEntry(), ACLFilledChecklist::al, Acl::Answer::allowed(), MemBuf::content(), ACLChecklist::fastCheck(), RefCount< C >::getRaw(), HTTPMSGLOCK(), MemBuf::init(), AccessLogEntry::reply, and ACLFilledChecklist::reply.
Referenced by httpHdrMangleList().
◆ httpHdrMangle()
|
static |
Checks the anonymizer (header_access) configuration.
- Return values
-
0 Header is explicitly blocked for removal 1 Header is explicitly allowed 1 Header has been replaced, the current version can be used. 1 Header has no access controls to test
Definition at line 286 of file HttpHeaderTools.cc.
References headerMangler::access_list, ACLFilledChecklist::al, Acl::Answer::allowed(), assert, debugs, ACLChecklist::fastCheck(), HeaderManglers::find(), RefCount< C >::getRaw(), HTTPMSGLOCK(), headerMangler::replacement, AccessLogEntry::reply, ACLFilledChecklist::reply, and HttpHeaderEntry::value.
Referenced by httpHdrMangleList().
◆ httpHdrMangleList()
void httpHdrMangleList | ( | HttpHeader * | l, |
HttpRequest * | request, | ||
const AccessLogEntryPointer & | al, | ||
req_or_rep_t | req_or_rep | ||
) |
Mangles headers for a list of headers.
Definition at line 336 of file HttpHeaderTools.cc.
References Config, HttpHeader::delAt(), HttpHeader::getEntry(), httpHdrAdd(), httpHdrMangle(), HttpHeaderInitPos, HttpHeader::refreshMask(), SquidConfig::reply_header_access, SquidConfig::reply_header_add, SquidConfig::request_header_access, SquidConfig::request_header_add, ROR_REPLY, and ROR_REQUEST.
Referenced by clientReplyContext::buildReplyHeader(), HttpStateData::httpBuildRequestHeader(), and Http::One::Server::writeControlMsgAndCall().
◆ httpHeaderAddContRange()
void httpHeaderAddContRange | ( | HttpHeader * | hdr, |
HttpHdrRangeSpec | spec, | ||
int64_t | ent_len | ||
) |
wrapper arrounf PutContRange
Definition at line 76 of file HttpHeaderTools.cc.
References assert, httpHdrContRangeCreate(), httpHdrContRangeSet(), and HttpHeader::putContRange().
Referenced by Ftp::Gateway::appendSuccessHeader(), Http::Stream::buildRangeHeader(), and clientPackRangeHdr().
◆ httpHeaderHasConnDir()
bool httpHeaderHasConnDir | ( | const HttpHeader * | hdr, |
const SBuf & | directive | ||
) |
- Returns
- true if a given directive is found in the Connection header field-value.
- Note
- if no Connection header exists we may check the Proxy-Connection header
Definition at line 91 of file HttpHeaderTools.cc.
References Http::CONNECTION, HttpHeader::getList(), Http::PROXY_CONNECTION, and strListIsMember().
Referenced by Adaptation::Icap::ModXact::parseIcapHead(), Adaptation::Icap::OptXact::parseResponse(), Http::Message::persistent(), and HttpStateData::statusIfComplete().
◆ httpHeaderMaskInit()
void httpHeaderMaskInit | ( | HttpHeaderMask * | mask, |
int | value | ||
) |
Definition at line 47 of file HttpHeaderTools.cc.
Referenced by HttpHeader::HttpHeader(), HttpHeader::clean(), HttpHeader::delByName(), and HttpHeader::refreshMask().
◆ httpHeaderParseInt()
parses an int field, complains if something went wrong, returns true on success
Definition at line 123 of file HttpHeaderTools.cc.
References assert, debugs, and xisdigit.
Referenced by HttpHeaderEntry::getInt(), HttpHdrCc::parse(), and HttpHdrSc::parse().
◆ httpHeaderParseOffset()
bool httpHeaderParseOffset | ( | const char * | start, |
int64_t * | offPtr, | ||
char ** | endPtr = nullptr |
||
) |
A strtoll(10) wrapper that checks for strtoll() failures and other problems. XXX: This function is not fully compatible with some HTTP syntax rules. Just like strtoll(), allows whitespace prefix, a sign, and any suffix. Requires at least one digit to be present. Sets "off" and "end" arguments if and only if no problems were found.
- Returns
- true if and only if no problems were found.
Definition at line 137 of file HttpHeaderTools.cc.
References debugs, and strtoll().
Referenced by Http::ContentLengthInterpreter::checkValue(), HttpHeaderEntry::getInt64(), httpHdrContRangeParseInit(), httpHdrRangeRespSpecParseInit(), and HttpHdrRangeSpec::parseInit().
◆ httpHeaderParseQuotedString()
Parses a quoted-string field (RFC 2616 section 2.2), complains if something went wrong, returns non-zero on success. Un-escapes quoted-pair characters found within the string. start should point at the first double-quote.
Definition at line 168 of file HttpHeaderTools.cc.
References String::append(), String::assign(), String::clean(), debugs, and String::termedBuf().
Referenced by HttpHdrCc::parse(), HttpHdrSc::parse(), Ftp::PrintReply(), and Http::SlowlyParseQuotedString().
◆ httpHeaderPutStrf()
void httpHeaderPutStrf | ( | HttpHeader * | hdr, |
Http::HdrType | id, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 54 of file HttpHeaderTools.cc.
References httpHeaderPutStrvf().
Referenced by ErrorState::BuildHttpReply(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), HttpStateData::httpBuildRequestHeader(), httpFixupAuthentication(), and HttpHeader::putAuth().
◆ httpHeaderPutStrvf()
|
static |
Definition at line 65 of file HttpHeaderTools.cc.
References MemBuf::buf, MemBuf::clean(), MemBuf::init(), HttpHeader::putStr(), and MemBuf::vappendf().
Referenced by httpHeaderPutStrf().
◆ httpHeaderQuoteString()
SBuf httpHeaderQuoteString | ( | const char * | raw | ) |
Definition at line 247 of file HttpHeaderTools.cc.
References SBuf::append(), and assert.
Referenced by Ftp::Relay::createHttpReply().