HttpHeader.cc
Go to the documentation of this file.
148HttpHeader::HttpHeader(const http_hdr_owner_type anOwner): owner(anOwner), len(0), conflictingContentLength_(false)
157HttpHeader::HttpHeader(const HttpHeader &other): owner(other.owner), len(other.len), conflictingContentLength_(false)
295 debugs(55, 7, "Updating header '" << Http::HeaderLookupTable.lookup(e->id).name << "' in cached entry");
302HttpHeader::Isolate(const char **parse_start, size_t l, const char **blk_start, const char **blk_end)
324HttpHeader::parse(const char *buf, size_t buf_len, bool atEnd, size_t &hdr_sz, Http::ContentLengthInterpreter &clen)
357 debugs(55, 7, "parsing hdr: (" << this << ")" << std::endl << getStringPrefix(header_start, hdrLen));
363 getStringPrefix(header_start, nulpos-header_start) << "}\nNULL\n{" << getStringPrefix(nulpos+1, hdrLen-(nulpos-header_start)-1));
417 char *p = (char *) this_line; /* XXX Warning! This destroys original header content and violates specifications somewhat */
459 const auto framingHeader = (e->id == Http::HdrType::CONTENT_LENGTH || e->id == Http::HdrType::TRANSFER_ENCODING);
462 debugs(55, warnOnError, "WARNING: obs-fold in framing-sensitive " << e->name << ": " << e->value);
780 debugs(55, 3, "empty list header: " << Http::HeaderLookupTable.lookup(id).name << "(" << id << ")");
814 debugs(55, 3, "empty list header: " << Http::HeaderLookupTable.lookup(id).name << "(" << id << ")");
903 if (e->id == Http::HdrType::OTHER && e->name.length() == namelen && e->name.caseCmp(name, namelen) == 0) {
918HttpHeader::getByNameListMember(const char *name, const char *member, const char separator) const
972 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
981 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
990 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
999 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1008 httpHeaderPutStrf(this, Http::HdrType::WWW_AUTHENTICATE, "%s realm=\"%s\"", auth_scheme, realm);
1124 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt); /* must be of an appropriate type */
1137 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftInt64); /* must be of an appropriate type */
1152 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123); /* must be of an appropriate type */
1168 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1184 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftStr); /* must be of an appropriate type */
1309 if (!base64_decode_update(&ctx, &decodedLen, reinterpret_cast<uint8_t*>(decodedAuthToken), fieldLen, field) ||
1322 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftETag); /* must be of an appropriate type */
1335 assert(Http::HeaderLookupTable.lookup(id).type == Http::HdrFieldType::ftDate_1123_or_ETag); /* must be of an appropriate type */
1393HttpHeaderEntry::parse(const char *field_start, const char *field_end, const http_hdr_owner_type msgType)
1411 debugs(55, 2, "ignoring huge header field (" << Raw("field_start", field_start, 100) << "...)");
1436 "WARNING: Whitespace after header name in '" << getStringPrefix(field_start, field_end-field_start) << "'");
1463 debugs(55, 9, "parsing HttpHeaderEntry: near '" << getStringPrefix(field_start, field_end-field_start) << "'");
1491 debugs(55, 2, "WARNING: found '" << theName << "' header of " << (field_end - value_start) << " bytes");
1552 debugs(55, 2, "cannot parse hdr field: '" << Http::HeaderLookupTable.lookup(id).name << ": " << context << "'");
1569 const char *name = valid_id ? Http::HeaderLookupTable.lookup(static_cast<Http::HdrType>(id)).name : "INVALID";
1677 && (item[mlen] == '=' || item[mlen] == separator || item[mlen] == ';' || item[mlen] == '\0')) {
1687HttpHeader::hasByNameListMember(const char *name, const char *member, const char separator) const
1701 && (item[mlen] == '=' || item[mlen] == separator || item[mlen] == ';' || item[mlen] == '\0')) {
void httpHdrCcUpdateStats(const HttpHdrCc *cc, StatHist *hist)
Definition: HttpHdrCc.cc:321
void httpHdrCcStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHdrCc.cc:331
void httpHdrContRangePackInto(const HttpHdrContRange *range, Packable *p)
Definition: HttpHdrContRange.cc:206
HttpHdrContRange * httpHdrContRangeParseCreate(const char *str)
Definition: HttpHdrContRange.cc:127
void httpHdrScStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHdrSc.cc:270
void httpHeaderMaskInit(HttpHeaderMask *mask, int value)
Definition: HttpHeaderTools.cc:47
bool httpHeaderParseOffset(const char *start, int64_t *value, char **endPtr)
Definition: HttpHeaderTools.cc:137
int httpHeaderParseInt(const char *start, int *value)
Definition: HttpHeaderTools.cc:123
void httpHeaderPutStrf(HttpHeader *hdr, Http::HdrType id, const char *fmt,...)
Definition: HttpHeaderTools.cc:54
const char * getStringPrefix(const char *str, size_t sz)
Definition: HttpHeaderTools.cc:110
static std::array< HttpHeaderStat, hoEnd > HttpHeaderStats
Definition: HttpHeader.cc:79
static void httpHeaderFieldStatDumper(StoreEntry *sentry, int, double val, double, int count)
Definition: HttpHeader.cc:1565
static void httpHeaderFldsPerHdrDumper(StoreEntry *sentry, int idx, double val, double, int count)
Definition: HttpHeader.cc:1582
static void httpHeaderRegisterWithCacheManager(void)
Definition: HttpHeader.cc:113
static void httpHeaderStatDump(const HttpHeaderStat *hs, StoreEntry *e)
Definition: HttpHeader.cc:1591
std::vector< HttpHeaderFieldStat > headerStatsTable(Http::HdrType::enumEnd_)
static void httpHeaderNoteParsedEntry(Http::HdrType id, String const &value, bool error)
Definition: HttpHeader.cc:1544
int strListGetItem(const String *str, char del, const char **item, int *ilen, const char **pos)
Definition: StrList.cc:86
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
int strListIsMember(const String *list, const SBuf &m, char del)
Definition: StrList.cc:46
SBuf getListMember(const String &list, const char *key, const char delimiter)
Definition: StrList.cc:144
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
Definition: StringConvert.h:17
void error(char *format,...)
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: ProtocolVersion.h:24
Definition: HttpHdrCc.h:44
bool parse(const String &s)
parse a header-string and fill in appropriate values.
Definition: HttpHdrCc.cc:95
Definition: HttpHdrContRange.h:18
Definition: HttpHeaderRange.h:52
static HttpHdrRange * ParseCreate(const String *range_spec)
Definition: HttpHdrRange.cc:210
Definition: HttpHdrSc.h:25
Definition: HttpHeader.h:51
static HttpHeaderEntry * parse(const char *field_start, const char *field_end, const http_hdr_owner_type msgType)
Definition: HttpHeader.cc:1393
size_t length() const
expected number of bytes written by packInto(), including ": " and CRLF
Definition: HttpHeader.h:64
HttpHeaderEntry(Http::HdrType id, const SBuf &name, const char *value)
Definition: HttpHeader.cc:1361
Definition: HttpHeader.h:75
SBuf getByNameListMember(const char *name, const char *member, const char separator) const
Definition: HttpHeader.cc:918
TimeOrTag getTimeOrTag(Http::HdrType id) const
Definition: HttpHeader.cc:1331
bool getByIdIfPresent(Http::HdrType id, String *result) const
Definition: HttpHeader.cc:872
int hasByNameListMember(const char *name, const char *member, const char separator) const
Definition: HttpHeader.cc:1687
int parse(const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
Definition: HttpHeader.cc:350
SBuf getListMember(Http::HdrType id, const char *member, const char separator) const
Definition: HttpHeader.cc:929
SBuf getAuthToken(Http::HdrType id, const char *auth_scheme) const
Definition: HttpHeader.cc:1276
HttpHeaderEntry * getEntry(HttpHeaderPos *pos) const
Definition: HttpHeader.cc:584
static bool Isolate(const char **parse_start, size_t l, const char **blk_start, const char **blk_end)
Definition: HttpHeader.cc:302
std::vector< HttpHeaderEntry *, PoolingAllocator< HttpHeaderEntry * > > entries
Definition: HttpHeader.h:175
void removeConnectionHeaderEntries()
Definition: HttpHeader.cc:1728
void addVia(const AnyP::ProtocolVersion &ver, const HttpHeader *from=nullptr)
Definition: HttpHeader.cc:946
bool hasNamed(const SBuf &s, String *value=nullptr) const
Definition: HttpHeader.cc:866
HttpHeaderEntry * findEntry(Http::HdrType id) const
Definition: HttpHeader.cc:603
void putAuth(const char *auth_scheme, const char *realm)
Definition: HttpHeader.cc:1005
void updateOrAddStr(Http::HdrType, const SBuf &)
Definition: HttpHeader.cc:1084
void packInto(Packable *p, bool mask_sensitive_info=false) const
Definition: HttpHeader.cc:540
HttpHeaderEntry * findLastEntry(Http::HdrType id) const
Definition: HttpHeader.cc:628
bool skipUpdateHeader(const Http::HdrType id) const
Definition: HttpHeader.cc:259
int hasListMember(Http::HdrType id, const char *member, const char separator) const
Definition: HttpHeader.cc:1663
const char * prohibitedAndIgnored() const
Definition: ContentLengthInterpreter.h:47
bool checkField(const String &field)
Definition: ContentLengthInterpreter.cc:153
bool sawBad
whether a malformed Content-Length value was present
Definition: ContentLengthInterpreter.h:58
bool needsSanitizing
Definition: ContentLengthInterpreter.h:63
const char * headerWideProblem
worst header-wide problem found (or nil)
Definition: ContentLengthInterpreter.h:54
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
Definition: MemBuf.h:24
Definition: Packable.h:53
virtual void append(const char *buf, int size)=0
Appends a c-string to existing packed data.
int caseCmp(const SBuf &S, const size_type n) const
shorthand version for case-insensitive compare()
Definition: SBuf.h:283
int cmp(const SBuf &S, const size_type n) const
shorthand version for compare()
Definition: SBuf.h:275
void rawAppendFinish(const char *start, size_type actualSize)
Definition: SBuf.cc:144
struct SquidConfig::@106 onoff
Definition: Store.h:42
Definition: SquidString.h:26
Definition: TimeOrTag.h:18
Definition: EnumIterator.h:222
char ThisCache[RFC2181_MAXHOSTNAMELEN<< 1]
size_t headersEnd(const char *mime, size_t l, bool &containsObsFold)
Definition: mime_header.cc:17
const char * ProtocolType_str[]
bool any_registered_header(const Http::HdrType id)
Definition: RegisteredHeaders.h:220
@ ftDate_1123_or_ETag
@ ftETag
@ ftDate_1123
@ ftInt64
@ ftStr
@ ftInt
bool any_HdrType_enum_value(const Http::HdrType id)
match any known header type, including OTHER and BAD
Definition: RegisteredHeaders.h:205
const HeaderLookupTable_t HeaderLookupTable
Definition: RegisteredHeaders.cc:60
bool any_valid_header(const Http::HdrType id)
match any valid header type, including OTHER but not BAD
Definition: RegisteredHeaders.h:212
void RegisterAction(char const *action, char const *desc, OBJH *handler, int pw_req_flag, int atomic)
Definition: Registration.cc:16
class Ping::pingStats_ stats
void Controller::create() STUB void Controller Controller nil
Definition: stub_libstore.cc:19
time_t ParseRfc1123(const char *)
Convert from RFC 1123 style time: "www, DD MMM YYYY hh:mm:ss ZZZ".
Definition: rfc1123.cc:153
Definition: base64.h:123