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 "HttpHeaderFieldInfo.h"
#include "HttpHeaderTools.h"
#include "HttpRequest.h"
#include "MemBuf.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)
 
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

#define SHORT_PREFIX_SIZE   512

Referenced by getStringPrefix().

Function Documentation

const char* getStringPrefix ( const char *  str,
size_t  sz 
)

handy to printf prefixes of potentially very long buffers

Definition at line 109 of file HttpHeaderTools.cc.

References buf, LOCAL_ARRAY, SHORT_PREFIX_SIZE, and xstrncpy().

Referenced by HttpHeaderEntry::parse(), and HttpHeader::parse().

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

Definition at line 369 of file HttpHeaderTools.cc.

References headerMangler::replacement, and storeAppendPrintf().

Referenced by HeaderManglers::dumpReplacement().

void httpHdrAdd ( HttpHeader heads,
HttpRequest request,
const AccessLogEntryPointer al,
HeaderWithAclList headersAdd 
)
static
static int httpHdrMangle ( HttpHeaderEntry e,
HttpRequest request,
HeaderManglers hms 
)
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 276 of file HttpHeaderTools.cc.

References headerMangler::access_list, allow_t::allowed(), assert, debugs, ACLChecklist::fastCheck(), HeaderManglers::find(), NULL, headerMangler::replacement, and HttpHeaderEntry::value.

Referenced by httpHdrMangleList().

void httpHeaderAddContRange ( HttpHeader hdr,
HttpHdrRangeSpec  spec,
int64_t  ent_len 
)
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 90 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().

void httpHeaderMaskInit ( HttpHeaderMask mask,
int  value 
)
int httpHeaderParseInt ( const char *  start,
int value 
)

parses an int field, complains if soemthing went wrong, returns true on success

Definition at line 122 of file HttpHeaderTools.cc.

References assert, debugs, and xisdigit.

Referenced by HttpHeaderEntry::getInt(), HttpHdrSc::parse(), and HttpHdrCc::parse().

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 136 of file HttpHeaderTools.cc.

References debugs, and strtoll().

Referenced by Http::ContentLengthInterpreter::checkValue(), HttpHeaderEntry::getInt64(), httpHdrContRangeParseInit(), httpHdrRangeRespSpecParseInit(), and HttpHdrRangeSpec::parseInit().

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 167 of file HttpHeaderTools.cc.

References String::append(), String::clean(), debugs, HERE(), len, String::limitInit(), and String::termedBuf().

Referenced by HttpHdrSc::parse(), Ssl::ErrorDetailFile::parse(), HttpHdrCc::parse(), and Ftp::PrintReply().

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

Definition at line 237 of file HttpHeaderTools.cc.

References SBuf::append(), and assert.

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors