HttpHeaderTools.cc File Reference
#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>
Include dependency graph for HttpHeaderTools.cc:

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 void header_mangler_clean ( headerMangler m)
static

◆ header_mangler_dump_access()

static void header_mangler_dump_access ( StoreEntry entry,
const char *  option,
const headerMangler m,
const char *  name 
)
static

◆ header_mangler_dump_replacement()

static void header_mangler_dump_replacement ( StoreEntry entry,
const char *  option,
const headerMangler m,
const char *  name 
)
static

Definition at line 390 of file HttpHeaderTools.cc.

References headerMangler::replacement, and storeAppendPrintf().

Referenced by HeaderManglers::dumpReplacement().

◆ httpHdrAdd()

◆ httpHdrMangle()

static int httpHdrMangle ( HttpHeaderEntry e,
HttpRequest request,
HeaderManglers hms,
const AccessLogEntryPointer al 
)
static

Checks the anonymizer (header_access) configuration.

Return values
0Header is explicitly blocked for removal
1Header is explicitly allowed
1Header has been replaced, the current version can be used.
1Header 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()

◆ httpHeaderAddContRange()

void httpHeaderAddContRange ( HttpHeader hdr,
HttpHdrRangeSpec  spec,
int64_t  ent_len 
)

◆ 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 
)

◆ httpHeaderParseInt()

int httpHeaderParseInt ( const char *  start,
int value 
)

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()

int httpHeaderParseQuotedString ( const char *  start,
const int  len,
String val 
)

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()

◆ httpHeaderPutStrvf()

static void httpHeaderPutStrvf ( HttpHeader hdr,
Http::HdrType  id,
const char *  fmt,
va_list  vargs 
)
static

◆ httpHeaderQuoteString()

SBuf httpHeaderQuoteString ( const char *  raw)

Definition at line 247 of file HttpHeaderTools.cc.

References SBuf::append(), and assert.

Referenced by Ftp::Relay::createHttpReply().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors