HttpHeader.cc
Go to the documentation of this file.
152 HttpHeader::HttpHeader(const http_hdr_owner_type anOwner): owner(anOwner), len(0), conflictingContentLength_(false)
161 HttpHeader::HttpHeader(const HttpHeader &other): owner(other.owner), len(other.len), conflictingContentLength_(false)
323 debugs(55, 7, "Updating header '" << Http::HeaderLookupTable.lookup(e->id).name << "' in cached entry");
330 HttpHeader::Isolate(const char **parse_start, size_t l, const char **blk_start, const char **blk_end)
352 HttpHeader::parse(const char *buf, size_t buf_len, bool atEnd, size_t &hdr_sz, Http::ContentLengthInterpreter &clen)
378 HttpHeader::parse(const char *header_start, size_t hdrLen, Http::ContentLengthInterpreter &clen)
385 debugs(55, 7, "parsing hdr: (" << this << ")" << std::endl << getStringPrefix(header_start, hdrLen));
391 getStringPrefix(header_start, nulpos-header_start) << "}\nNULL\n{" << getStringPrefix(nulpos+1, hdrLen-(nulpos-header_start)-1));
445 char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */
487 const auto framingHeader = (e->id == Http::HdrType::CONTENT_LENGTH || e->id == Http::HdrType::TRANSFER_ENCODING);
490 debugs(55, warnOnError, "WARNING: obs-fold in framing-sensitive " << e->name << ": " << e->value);
833 debugs(55, 3, "empty list header: " << Http::HeaderLookupTable.lookup(id).name << "(" << id << ")");
867 debugs(55, 3, "empty list header: " << Http::HeaderLookupTable.lookup(id).name << "(" << id << ")");
956 if (e->id == Http::HdrType::OTHER && e->name.length() == namelen && e->name.caseCmp(name, namelen) == 0) {
971 HttpHeader::getByNameListMember(const char *name, const char *member, const char separator) const
1028 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
1037 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
1046 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
1055 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1064 httpHeaderPutStrf(this, Http::HdrType::WWW_AUTHENTICATE, "%s realm=\"%s\"", auth_scheme, realm);
1152 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
1165 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
1180 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
1196 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1212 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1337 if (!base64_decode_update(&ctx, &decodedLen, reinterpret_cast<uint8_t*>(decodedAuthToken), fieldLen, field) ||
1350 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftETag); /* must be of an appropriate type */
1363 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123_or_ETag); /* must be of an appropriate type */
1421 HttpHeaderEntry::parse(const char *field_start, const char *field_end, const http_hdr_owner_type msgType)
1439 debugs(55, 2, "ignoring huge header field (" << Raw("field_start", field_start, 100) << "...)");
1464 "WARNING: Whitespace after header name in '" << getStringPrefix(field_start, field_end-field_start) << "'");
1491 debugs(55, 9, "parsing HttpHeaderEntry: near '" << getStringPrefix(field_start, field_end-field_start) << "'");
1519 debugs(55, 2, "WARNING: found '" << theName << "' header of " << (field_end - value_start) << " bytes");
1580 debugs(55, 2, "cannot parse hdr field: '" << Http::HeaderLookupTable.lookup(id).name << ": " << context << "'");
1597 const char *name = valid_id ? Http::HeaderLookupTable.lookup(static_cast<Http::HdrType>(id)).name : "INVALID";
1705 && (item[mlen] == '=' || item[mlen] == separator || item[mlen] == ';' || item[mlen] == '\0')) {
1715 HttpHeader::hasByNameListMember(const char *name, const char *member, const char separator) const
bool needsSanitizing
Definition: ContentLengthInterpreter.h:63
bool any_registered_header(const Http::HdrType id)
Definition: RegisteredHeaders.h:220
class Ping::pingStats_ stats
static HttpHeaderEntry * parse(const char *field_start, const char *field_end, const http_hdr_owner_type msgType)
Definition: HttpHeader.cc:1421
@ ftInvalid
SBuf getListMember(const String &list, const char *key, const char delimiter)
Definition: StrList.cc:144
void httpHdrScStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHdrSc.cc:272
int hasListMember(Http::HdrType id, const char *member, const char separator) const
Definition: HttpHeader.cc:1691
Definition: HttpHdrCc.h:44
Definition: HttpHeaderRange.h:52
HttpHeaderEntry * findLastEntry(Http::HdrType id) const
Definition: HttpHeader.cc:656
void error(char *format,...)
int parse(const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
Definition: HttpHeader.cc:378
const char * ProtocolType_str[]
bool checkField(const String &field)
Definition: ContentLengthInterpreter.cc:153
virtual void append(const char *buf, int size)=0
Appends a c-string to existing packed data.
void rawAppendFinish(const char *start, size_type actualSize)
Definition: SBuf.cc:144
time_t ParseRfc1123(const char *)
Convert from RFC 1123 style time: "www, DD MMM YYYY hh:mm:ss ZZZ".
Definition: rfc1123.cc:159
void httpHdrCcUpdateStats(const HttpHdrCc *cc, StatHist *hist)
Definition: HttpHdrCc.cc:321
static bool Isolate(const char **parse_start, size_t l, const char **blk_start, const char **blk_end)
Definition: HttpHeader.cc:330
int hasByNameListMember(const char *name, const char *member, const char separator) const
Definition: HttpHeader.cc:1715
char ThisCache[RFC2181_MAXHOSTNAMELEN<< 1]
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
Definition: HttpHeaderTools.cc:53
Definition: Packable.h:53
Definition: base64.h:123
static void httpHeaderFldsPerHdrDumper(StoreEntry *sentry, int idx, double val, double, int count)
Definition: HttpHeader.cc:1610
bool sawBad
whether a malformed Content-Length value was present
Definition: ContentLengthInterpreter.h:58
bool skipUpdateHeader(const Http::HdrType id) const
Definition: HttpHeader.cc:283
bool any_HdrType_enum_value(const Http::HdrType id)
match any known header type, including OTHER and BAD
Definition: RegisteredHeaders.h:205
Definition: TimeOrTag.h:18
Definition: HttpHeader.h:51
static std::array< HttpHeaderStat, hoEnd > HttpHeaderStats
Definition: HttpHeader.cc:78
TimeOrTag getTimeOrTag(Http::HdrType id) const
Definition: HttpHeader.cc:1359
Definition: EnumIterator.h:226
void strListAdd(String &str, const char *item, const size_t itemSize, const char delimiter)
Appends the given item of a given size to a delimiter-separated list in str.
Definition: StrList.cc:18
bool hasNamed(const SBuf &s, String *value=0) const
Definition: HttpHeader.cc:919
int strListIsMember(const String *list, const SBuf &m, char del)
Definition: StrList.cc:46
bool parse(const String &s)
parse a header-string and fill in appropriate values.
Definition: HttpHdrCc.cc:95
char const * visible_appname_string
const char * prohibitedAndIgnored() const
Definition: ContentLengthInterpreter.h:47
std::vector< HttpHeaderFieldStat > headerStatsTable(Http::HdrType::enumEnd_)
void putAuth(const char *auth_scheme, const char *realm)
Definition: HttpHeader.cc:1061
std::vector< HttpHeaderEntry *, PoolingAllocator< HttpHeaderEntry * > > entries
Definition: HttpHeader.h:171
void putWarning(const int code, const char *const text)
add a Warning header
Definition: HttpHeader.cc:1132
Definition: MemBuf.h:24
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
Definition: StringConvert.h:17
bool httpHeaderParseOffset(const char *start, int64_t *value, char **endPtr)
Definition: HttpHeaderTools.cc:136
SBuf getAuthToken(Http::HdrType id, const char *auth_scheme) const
Definition: HttpHeader.cc:1304
int base64_decode_update(struct base64_decode_ctx *ctx, size_t *dst_length, uint8_t *dst, size_t src_length, const char *src)
Definition: base64.c:129
Definition: SquidString.h:26
bool any_valid_header(const Http::HdrType id)
match any valid header type, including OTHER but not BAD
Definition: RegisteredHeaders.h:212
const HeaderTableRecord & lookup(const char *buf, const std::size_t len) const
look record type up by name (C-string and length)
Definition: RegisteredHeaders.cc:32
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:568
HttpHdrContRange * httpHdrContRangeParseCreate(const char *str)
Definition: HttpHdrContRange.cc:127
static void httpHeaderNoteParsedEntry(Http::HdrType id, String const &value, bool error)
Definition: HttpHeader.cc:1572
void removeConnectionHeaderEntries()
Definition: HttpHeader.cc:1756
const HeaderLookupTable_t HeaderLookupTable
Definition: RegisteredHeaders.cc:60
Definition: HttpHdrSc.h:25
const char * getStringPrefix(const char *str, size_t sz)
Definition: HttpHeaderTools.cc:109
HttpHeaderEntry * findEntry(Http::HdrType id) const
Definition: HttpHeader.cc:631
Definition: Store.h:42
static HttpHdrRange * ParseCreate(const String *range_spec)
Definition: HttpHdrRange.cc:210
static void httpHeaderRegisterWithCacheManager(void)
Definition: HttpHeader.cc:111
void httpHdrCcStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHdrCc.cc:331
struct SquidConfig::@110 onoff
SBuf getByNameListMember(const char *name, const char *member, const char separator) const
Definition: HttpHeader.cc:971
bool getByIdIfPresent(Http::HdrType id, String *result) const
Definition: HttpHeader.cc:925
static void httpHeaderFieldStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHeader.cc:1593
int httpHeaderParseInt(const char *start, int *value)
Definition: HttpHeaderTools.cc:122
void Controller::create() STUB void Controller Controller nil
Definition: stub_libstore.cc:19
HttpHeaderEntry(Http::HdrType id, const SBuf &name, const char *value)
Definition: HttpHeader.cc:1389
Definition: HttpHdrContRange.h:18
SBuf getListMember(Http::HdrType id, const char *member, const char separator) const
Definition: HttpHeader.cc:982
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
Definition: SBuf.h:283
const char * headerWideProblem
worst header-wide problem found (or nil)
Definition: ContentLengthInterpreter.h:54
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:612
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
void httpHdrContRangePackInto(const HttpHdrContRange *range, Packable *p)
Definition: HttpHdrContRange.cc:206
void httpHeaderMaskInit(HttpHeaderMask *mask, int value)
Definition: HttpHeaderTools.cc:46
void addVia(const AnyP::ProtocolVersion &ver, const HttpHeader *from=0)
Definition: HttpHeader.cc:999
size_t headersEnd(const char *mime, size_t l, bool &containsObsFold)
Definition: mime_header.cc:17
static void httpHeaderStatDump(const HttpHeaderStat *hs, StoreEntry *e)
Definition: HttpHeader.cc:1619
Definition: HttpHeader.h:72
int strListGetItem(const String *str, char del, const char **item, int *ilen, const char **pos)
Definition: StrList.cc:86
Definition: ProtocolVersion.h:24