#include <HttpHeader.h>

Inheritance diagram for HttpHeader:
Collaboration diagram for HttpHeader:

Public Member Functions

 HttpHeader (const http_hdr_owner_type owner)
 
 HttpHeader (const HttpHeader &other)
 
 ~HttpHeader ()
 
HttpHeaderoperator= (const HttpHeader &other)
 
void clean ()
 
void append (const HttpHeader *src)
 
void update (const HttpHeader *fresh)
 
bool needUpdate (const HttpHeader *fresh) const
 
void compact ()
 
int parse (const char *header_start, size_t len, Http::ContentLengthInterpreter &interpreter)
 
int parse (const char *buf, size_t buf_len, bool atEnd, size_t &hdr_sz, Http::ContentLengthInterpreter &interpreter)
 
void packInto (Packable *p, bool mask_sensitive_info=false) const
 
HttpHeaderEntrygetEntry (HttpHeaderPos *pos) const
 
HttpHeaderEntryfindEntry (Http::HdrType id) const
 
int delByName (const SBuf &name)
 
int delByName (const char *name)
 
int delById (Http::HdrType id)
 
void delAt (HttpHeaderPos pos, int &headers_deleted)
 
void refreshMask ()
 
void addEntry (HttpHeaderEntry *e)
 
String getList (Http::HdrType id) const
 
bool getList (Http::HdrType id, String *s) const
 
bool conflictingContentLength () const
 
String getStrOrList (Http::HdrType id) const
 
String getByName (const SBuf &name) const
 
String getByName (const char *name) const
 
String getById (Http::HdrType id) const
 
bool getByIdIfPresent (Http::HdrType id, String *result) const
 
bool hasNamed (const SBuf &s, String *value=nullptr) const
 
bool hasNamed (const char *name, unsigned int namelen, String *value=nullptr) const
 
SBuf getByNameListMember (const char *name, const char *member, const char separator) const
 
SBuf getListMember (Http::HdrType id, const char *member, const char separator) const
 
int has (Http::HdrType id) const
 
void addVia (const AnyP::ProtocolVersion &ver, const HttpHeader *from=nullptr)
 
void putInt (Http::HdrType id, int number)
 
void putInt64 (Http::HdrType id, int64_t number)
 
void putTime (Http::HdrType id, time_t htime)
 
void putStr (Http::HdrType id, const char *str)
 
void putAuth (const char *auth_scheme, const char *realm)
 
void putCc (const HttpHdrCc &cc)
 
void putContRange (const HttpHdrContRange *cr)
 
void putRange (const HttpHdrRange *range)
 
void putSc (HttpHdrSc *sc)
 
void putExt (const char *name, const char *value)
 
void updateOrAddStr (Http::HdrType, const SBuf &)
 
int getInt (Http::HdrType id) const
 
int64_t getInt64 (Http::HdrType id) const
 
time_t getTime (Http::HdrType id) const
 
const char * getStr (Http::HdrType id) const
 
const char * getLastStr (Http::HdrType id) const
 
HttpHdrCcgetCc () const
 
HttpHdrRangegetRange () const
 
HttpHdrScgetSc () const
 
HttpHdrContRangegetContRange () const
 
SBuf getAuthToken (Http::HdrType id, const char *auth_scheme) const
 
ETag getETag (Http::HdrType id) const
 
TimeOrTag getTimeOrTag (Http::HdrType id) const
 
int hasListMember (Http::HdrType id, const char *member, const char separator) const
 
int hasByNameListMember (const char *name, const char *member, const char separator) const
 
void removeHopByHopEntries ()
 
bool chunked () const
 
bool unsupportedTe () const
 whether message used an unsupported and/or invalid Transfer-Encoding More...
 

Public Attributes

std::vector< HttpHeaderEntry *, PoolingAllocator< HttpHeaderEntry * > > entries
 
HttpHeaderMask mask
 
http_hdr_owner_type owner
 
int len
 

Protected Member Functions

void removeConnectionHeaderEntries ()
 
bool skipUpdateHeader (const Http::HdrType id) const
 

Static Protected Member Functions

static bool Isolate (const char **parse_start, size_t l, const char **blk_start, const char **blk_end)
 

Private Member Functions

HttpHeaderEntryfindLastEntry (Http::HdrType id) const
 

Private Attributes

bool conflictingContentLength_
 
bool teUnsupported_ = false
 

Detailed Description

Definition at line 74 of file HttpHeader.h.

Constructor & Destructor Documentation

◆ HttpHeader() [1/2]

HttpHeader::HttpHeader ( const http_hdr_owner_type  owner)
explicit

Definition at line 148 of file HttpHeader.cc.

References assert, debugs, entries, hoEnd, hoNone, httpHeaderMaskInit(), mask, and owner.

◆ HttpHeader() [2/2]

HttpHeader::HttpHeader ( const HttpHeader other)

Definition at line 157 of file HttpHeader.cc.

References entries, httpHeaderMaskInit(), mask, and update().

◆ ~HttpHeader()

HttpHeader::~HttpHeader ( )

Definition at line 164 of file HttpHeader.cc.

References clean().

Member Function Documentation

◆ addEntry()

◆ addVia()

void HttpHeader::addVia ( const AnyP::ProtocolVersion ver,
const HttpHeader from = nullptr 
)

◆ append()

void HttpHeader::append ( const HttpHeader src)

Definition at line 232 of file HttpHeader.cc.

References addEntry(), assert, debugs, and entries.

Referenced by ESIVarState::ESIVarState(), HttpReply::clone(), and HttpRequest::clone().

◆ chunked()

bool HttpHeader::chunked ( ) const
inline

whether the message uses chunked Transfer-Encoding optimized implementation relies on us rejecting/removing other codings

Definition at line 169 of file HttpHeader.h.

References has(), and Http::TRANSFER_ENCODING.

Referenced by HttpRequest::checkEntityFraming(), clientProcessRequest(), HttpReply::expectingBody(), HttpRequest::expectingBody(), and HttpStateData::processReplyHeader().

◆ clean()

◆ compact()

void HttpHeader::compact ( )

Definition at line 712 of file HttpHeader.cc.

References entries.

Referenced by HttpReply::recreateOnNotModified().

◆ conflictingContentLength()

bool HttpHeader::conflictingContentLength ( ) const
inline

Definition at line 113 of file HttpHeader.h.

References conflictingContentLength_.

Referenced by HttpRequest::checkEntityFraming().

◆ delAt()

◆ delById()

◆ delByName() [1/2]

int HttpHeader::delByName ( const char *  name)
inline
Deprecated:
use SBuf method instead. performance regression: reallocates

Definition at line 106 of file HttpHeader.h.

References delByName().

Referenced by delByName().

◆ delByName() [2/2]

int HttpHeader::delByName ( const SBuf name)

deletes all fields with a given name, if any.

Returns
#fields deleted

Definition at line 648 of file HttpHeader.cc.

References CBIT_SET, debugs, delAt(), getEntry(), HttpHeaderInitPos, httpHeaderMaskInit(), and mask.

Referenced by update().

◆ findEntry()

◆ findLastEntry()

HttpHeaderEntry * HttpHeader::findLastEntry ( Http::HdrType  id) const
private

Definition at line 628 of file HttpHeader.cc.

References Http::any_registered_header(), assert, CBIT_TEST, entries, Http::HeaderLookupTable, and mask.

Referenced by getLastStr().

◆ getAuthToken()

◆ getById()

String HttpHeader::getById ( Http::HdrType  id) const

Definition at line 858 of file HttpHeader.cc.

References getByIdIfPresent().

◆ getByIdIfPresent()

bool HttpHeader::getByIdIfPresent ( Http::HdrType  id,
String result 
) const

returns true iff a [possibly empty] field identified by id is there when returning true, also sets the result parameter (if it is not nil)

Definition at line 872 of file HttpHeader.cc.

References Http::BAD_HDR, getStrOrList(), and has().

Referenced by getById(), hasNamed(), and parse().

◆ getByName() [1/2]

String HttpHeader::getByName ( const char *  name) const

Definition at line 840 of file HttpHeader.cc.

References hasNamed().

◆ getByName() [2/2]

◆ getByNameListMember()

SBuf HttpHeader::getByNameListMember ( const char *  name,
const char *  member,
const char  separator 
) const

searches for the first matching key=value pair within the name-identified field

Returns
the value of the found pair or an empty string

Definition at line 918 of file HttpHeader.cc.

References assert, getByName(), and getListMember().

Referenced by Format::Format::assemble().

◆ getCc()

◆ getContRange()

◆ getEntry()

◆ getETag()

◆ getInt()

◆ getInt64()

◆ getLastStr()

◆ getList() [1/2]

◆ getList() [2/2]

bool HttpHeader::getList ( Http::HdrType  id,
String s 
) const

◆ getListMember()

SBuf HttpHeader::getListMember ( Http::HdrType  id,
const char *  member,
const char  separator 
) const

searches for the first matching key=value pair within the field

Returns
the value of the found pair or an empty string

Definition at line 929 of file HttpHeader.cc.

References Http::any_registered_header(), assert, getListMember(), and getStrOrList().

Referenced by ESIVariableCookie::eval().

◆ getRange()

◆ getSc()

◆ getStr()

◆ getStrOrList()

◆ getTime()

◆ getTimeOrTag()

◆ has()

◆ hasByNameListMember()

int HttpHeader::hasByNameListMember ( const char *  name,
const char *  member,
const char  separator 
) const

Definition at line 1687 of file HttpHeader.cc.

References assert, getByName(), and strListGetItem().

Referenced by Adaptation::Icap::Options::configure().

◆ hasListMember()

◆ hasNamed() [1/2]

◆ hasNamed() [2/2]

bool HttpHeader::hasNamed ( const SBuf s,
String value = nullptr 
) const

returns true iff a [possibly empty] named field is there when returning true, also sets the value parameter (if it is not nil)

Definition at line 866 of file HttpHeader.cc.

References hasNamed(), SBuf::length(), and SBuf::rawContent().

Referenced by getByName(), hasNamed(), ACLHTTPHeaderData::match(), needUpdate(), and SlowlyParseQuotedField().

◆ Isolate()

bool HttpHeader::Isolate ( const char **  parse_start,
size_t  l,
const char **  blk_start,
const char **  blk_end 
)
staticprotected

either finds the end of headers or returns false If the end was found: *parse_start points to the first character after the header delimiter *blk_start points to the first header character (i.e. old parse_start value) *blk_end points to the first header delimiter character (CR or LF in CR?LF). If block starts where it ends, then there are no fields in the header.

Definition at line 302 of file HttpHeader.cc.

References assert, and headersEnd().

Referenced by parse().

◆ needUpdate()

bool HttpHeader::needUpdate ( const HttpHeader fresh) const
Returns
whether calling update(fresh) would change our set of fields

Definition at line 245 of file HttpHeader.cc.

References entries, getByName(), hasNamed(), and skipUpdateHeader().

Referenced by HttpReply::recreateOnNotModified().

◆ operator=()

HttpHeader & HttpHeader::operator= ( const HttpHeader other)

Definition at line 171 of file HttpHeader.cc.

References assert, clean(), conflictingContentLength_, len, owner, teUnsupported_, and update().

◆ packInto()

◆ parse() [1/2]

int HttpHeader::parse ( const char *  buf,
size_t  buf_len,
bool  atEnd,
size_t hdr_sz,
Http::ContentLengthInterpreter interpreter 
)

Parses headers stored in a buffer.

Returns
1 and sets hdr_sz on success
0 when needs more data
-1 on error

Definition at line 324 of file HttpHeader.cc.

References Isolate(), and parse().

◆ parse() [2/2]

◆ putAuth()

void HttpHeader::putAuth ( const char *  auth_scheme,
const char *  realm 
)

◆ putCc()

◆ putContRange()

void HttpHeader::putContRange ( const HttpHdrContRange cr)

◆ putExt()

void HttpHeader::putExt ( const char *  name,
const char *  value 
)

◆ putInt()

void HttpHeader::putInt ( Http::HdrType  id,
int  number 
)

◆ putInt64()

◆ putRange()

void HttpHeader::putRange ( const HttpHdrRange range)

◆ putSc()

void HttpHeader::putSc ( HttpHdrSc sc)

◆ putStr()

◆ putTime()

◆ refreshMask()

◆ removeConnectionHeaderEntries()

void HttpHeader::removeConnectionHeaderEntries ( )
protected

◆ removeHopByHopEntries()

◆ skipUpdateHeader()

bool HttpHeader::skipUpdateHeader ( const Http::HdrType  id) const
protected

Definition at line 259 of file HttpHeader.cc.

References Http::VARY.

Referenced by needUpdate(), and update().

◆ unsupportedTe()

bool HttpHeader::unsupportedTe ( ) const
inline

Definition at line 172 of file HttpHeader.h.

References teUnsupported_.

Referenced by HttpRequest::checkEntityFraming().

◆ update()

void HttpHeader::update ( const HttpHeader fresh)

◆ updateOrAddStr()

void HttpHeader::updateOrAddStr ( Http::HdrType  id,
const SBuf newValue 
)

Ensures that the header has the given field, removing or replacing any same-name fields with conflicting values as needed.

Definition at line 1084 of file HttpHeader.cc.

References addEntry(), Http::any_registered_header(), assert, Assure, SBuf::c_str(), CBIT_TEST, SBuf::cmp(), debugs, entries, Http::ftStr, Http::HeaderLookupTable, SBuf::length(), mask, SBuf::plength(), SBuf::rawContent(), and String::SizeMaxXXX().

Referenced by addVia(), ErrorState::BuildHttpReply(), Http::One::Server::buildHttpRequest(), and Ftp::Server::setDataCommand().

Member Data Documentation

◆ conflictingContentLength_

bool HttpHeader::conflictingContentLength_
private

found different Content-Length fields

Definition at line 194 of file HttpHeader.h.

Referenced by clean(), conflictingContentLength(), operator=(), and parse().

◆ entries

◆ len

int HttpHeader::len

length when packed, not counting terminating null-byte

Definition at line 178 of file HttpHeader.h.

Referenced by addEntry(), clean(), delAt(), operator=(), peerDigestRequest(), HttpReply::prefixLen(), and HttpRequest::prefixLen().

◆ mask

◆ owner

http_hdr_owner_type HttpHeader::owner

request or reply

Definition at line 177 of file HttpHeader.h.

Referenced by HttpHeader(), clean(), getCc(), getSc(), HttpStateData::httpBuildRequestHeader(), operator=(), and parse().

◆ teUnsupported_

bool HttpHeader::teUnsupported_ = false
private

unsupported encoding, unnecessary syntax characters, and/or invalid field-value found in Transfer-Encoding header

Definition at line 197 of file HttpHeader.h.

Referenced by clean(), operator=(), parse(), and unsupportedTe().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors