#include <HttpReply.h>

Inheritance diagram for HttpReply:
Collaboration diagram for HttpReply:

Public Types

typedef RefCount< HttpReplyPointer
enum  Sources {
  srcUnknown = 0 ,
  srcHttps = 1 << 0 ,
  srcFtps = 1 << 1 ,
  srcIcaps = 1 << 2 ,
  srcEcaps = 1 << 3 ,
  srcHttp = 1 << (16 + 0) ,
  srcFtp = 1 << (16 + 1) ,
  srcIcap = 1 << (16 + 2) ,
  srcEcap = 1 << (16 + 3) ,
  srcWhois = 1 << (16 + 15) ,
  srcUnsafe = 0xFFFF0000 ,
  srcSafe = 0x0000FFFF
 Who may have created or modified this message? More...
enum  ParseState {
  psReadyToParseStartLine = 0 ,
  psReadyToParseHeaders ,
  psParsed ,
 parse state of HttpReply or HttpRequest More...

Public Member Functions

 HttpReply ()
 ~HttpReply () override
void reset () override
bool sanityCheckStartLine (const char *buf, const size_t hdr_len, Http::StatusCode *error) override
const HttpHdrContRangecontentRange () const
int httpMsgParseError () override
bool expectingBody (const HttpRequestMethod &, int64_t &) const override
bool inheritProperties (const Http::Message *) override
Pointer recreateOnNotModified (const HttpReply &reply304) const
void setHeaders (Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
MemBufpack () const
HttpReplyPointer make304 () const
void redirect (Http::StatusCode, const char *)
int64_t bodySize (const HttpRequestMethod &) const
bool receivedBodyTooLarge (HttpRequest &, int64_t receivedBodySize)
bool expectedBodyTooLarge (HttpRequest &request)
int validatorsMatch (HttpReply const *other) const
void packHeadersUsingFastPacker (Packable &p) const
void packHeadersUsingSlowPacker (Packable &p) const
 same as packHeadersUsingFastPacker() but assumes that p cannot quickly process small additions More...
HttpReplyclone () const override
void hdrCacheInit () override
bool olderThan (const HttpReply *them) const
void removeIrrelevantContentLength ()
 Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2). More...
void configureContentLengthInterpreter (Http::ContentLengthInterpreter &) override
 configures the interpreter as needed More...
bool parseHeader (Http1::Parser &hp)
 parses reply header using Parser More...
void packInto (Packable *, bool full_uri) const
 produce a message copy, except for a few connection-specific settings More...
void setContentLength (int64_t)
 [re]sets Content-Length header and cached value More...
bool persistent () const
void putCc (const HttpHdrCc *otherCc)
 copies Cache-Control header to this message More...
bool parse (const char *buf, const size_t sz, bool eol, Http::StatusCode *error)
bool parseCharBuf (const char *buf, ssize_t end)
int httpMsgParseStep (const char *buf, int len, int atEnd)
void firstLineBuf (MemBuf &)
 useful for debugging More...

Static Public Member Functions

static HttpReplyPointer MakeConnectionEstablished ()
 construct and return an HTTP/200 (Connection Established) response More...

Public Attributes

time_t date
time_t last_modified
time_t expires
String content_type
short int keep_alive
Http::StatusLine sline
HttpBody body
String protoPrefix
bool do_clean
AnyP::ProtocolVersion http_ver
HttpHeader header
HttpHdrCccache_control = nullptr
int hdr_sz = 0
int64_t content_length = 0
ParseState pstate = Http::Message::psReadyToParseStartLine
 the current parsing state More...
BodyPipe::Pointer body_pipe
 optional pipeline to receive message body More...
uint32_t sources = 0
 The message sources. More...

Protected Member Functions

void packFirstLineInto (Packable *p, bool) const override
bool parseFirstLine (const char *start, const char *end) override
bool parseHeader (Http1::Parser &, Http::ContentLengthInterpreter &)

Private Member Functions

void init ()
void clean ()
void hdrCacheClean ()
void packInto (MemBuf &) const
MemBufpacked304Reply () const
time_t hdrExpirationTime ()
void calcMaxBodySize (HttpRequest &request) const

Private Attributes

int64_t bodySizeMax
 parsed Content-Range; nil for non-206 responses! More...

Detailed Description

Definition at line 24 of file HttpReply.h.

Member Typedef Documentation

◆ Pointer

Definition at line 29 of file HttpReply.h.

Member Enumeration Documentation

◆ ParseState

enum Http::Message::ParseState

Definition at line 86 of file Message.h.

◆ Sources

enum Http::Message::Sources

https_port or bumped http_port tunnel; HTTPS server


ftps_port or SFTP server; currently unused


Secure ICAP service.


eCAP service that is considered secure; currently unused


http_port or HTTP server


ftp_port or FTP server


traditional ICAP service without encryption


eCAP service that uses insecure libraries/daemons


Whois server.


Unsafe sources mask.


Safe sources mask.

Definition at line 29 of file Message.h.

Constructor & Destructor Documentation

◆ HttpReply()

HttpReply::HttpReply ( )

Definition at line 28 of file HttpReply.cc.

References init().

Referenced by clone().

◆ ~HttpReply()

HttpReply::~HttpReply ( )

Definition at line 42 of file HttpReply.cc.

References clean(), and do_clean.

Member Function Documentation

◆ bodySize()

◆ calcMaxBodySize()

void HttpReply::calcMaxBodySize ( HttpRequest request) const

◆ clean()

void HttpReply::clean ( )

◆ clone()

HttpReply * HttpReply::clone ( ) const

Clone this reply. Could be done as a copy-contructor but we do not want to accidentally copy a HttpReply..

Implements Http::Message.

Definition at line 572 of file HttpReply.cc.

References HttpReply(), HttpHeader::append(), Http::Message::body_pipe, Http::Message::hdr_sz, hdrCacheInit(), Http::Message::header, Http::Message::http_ver, Http::Message::pstate, and sline.

Referenced by clientReplyContext::cloneReply(), and recreateOnNotModified().

◆ configureContentLengthInterpreter()

void HttpReply::configureContentLengthInterpreter ( Http::ContentLengthInterpreter )

◆ contentRange()

const HttpHdrContRange * HttpReply::contentRange ( ) const
parsed Content-Range for a 206 response and nil for others

Definition at line 342 of file HttpReply.cc.

References assert, content_range, Http::scPartialContent, sline, and Http::StatusLine::status().

Referenced by Http::Stream::buildRangeHeader(), HttpHdrRange::canonize(), and Client::haveParsedReplyHeaders().

◆ expectedBodyTooLarge()

bool HttpReply::expectedBodyTooLarge ( HttpRequest request)

Checks whether expected body exceeds known maximum size. Requires a prior call to calcMaxBodySize().

Definition at line 524 of file HttpReply.cc.

References bodySizeMax, calcMaxBodySize(), debugs, expectingBody(), and HttpRequest::method.

Referenced by clientReplyContext::processReplyAccess().

◆ expectingBody()

bool HttpReply::expectingBody ( const HttpRequestMethod req_method,
int64_t &  theSize 
) const

◆ firstLineBuf()

void Http::Message::firstLineBuf ( MemBuf mb)

Definition at line 281 of file Message.cc.

◆ hdrCacheClean()

void HttpReply::hdrCacheClean ( )

◆ hdrCacheInit()

◆ hdrExpirationTime()

◆ httpMsgParseError()

int HttpReply::httpMsgParseError ( )

◆ httpMsgParseStep()

int Http::Message::httpMsgParseStep ( const char *  buf,
int  len,
int  atEnd 

parses a 0-terminated buffer into Http::Message.

Return values
0need more data (partial parse)
-1parse error

Definition at line 162 of file Message.cc.

References assert, httpMsgIsolateStart(), Http::Message::psParsed, Http::Message::psReadyToParseHeaders, and Http::Message::psReadyToParseStartLine.

◆ inheritProperties()

bool HttpReply::inheritProperties ( const Http::Message aMsg)

Implements Http::Message.

Definition at line 588 of file HttpReply.cc.

References keep_alive, and Http::Message::sources.

◆ init()

void HttpReply::init ( void  )

◆ make304()

◆ MakeConnectionEstablished()

HttpReplyPointer HttpReply::MakeConnectionEstablished ( )


HttpReply::MEMPROXY_CLASS ( HttpReply  )

◆ olderThan()

bool HttpReply::olderThan ( const HttpReply them) const

whether our Date header value is smaller than theirs

false if any information is missing

Definition at line 599 of file HttpReply.cc.

References date.

Referenced by HttpStateData::haveParsedReplyHeaders().

◆ pack()

MemBuf * HttpReply::pack ( ) const

◆ packed304Reply()

MemBuf * HttpReply::packed304Reply ( ) const
construct 304 reply and pack it into a MemBuf

Definition at line 156 of file HttpReply.cc.

References make304().

◆ packFirstLineInto()

void HttpReply::packFirstLineInto ( Packable p,
) const

Implements Http::Message.

Definition at line 155 of file HttpReply.h.

References Http::StatusLine::packInto(), and sline.

◆ packHeadersUsingFastPacker()

void HttpReply::packHeadersUsingFastPacker ( Packable p) const

adds status line and header to the given Packable assumes that p can quickly process small additions

Definition at line 85 of file HttpReply.cc.

References Packable::append(), Http::Message::header, Http::StatusLine::packInto(), HttpHeader::packInto(), and sline.

Referenced by packHeadersUsingSlowPacker(), packInto(), and AccessLogEntry::packReplyHeaders().

◆ packHeadersUsingSlowPacker()

void HttpReply::packHeadersUsingSlowPacker ( Packable p) const

◆ packInto() [1/2]

void HttpReply::packInto ( MemBuf buf) const

Definition at line 102 of file HttpReply.cc.

References body, packHeadersUsingFastPacker(), and HttpBody::packInto().

Referenced by pack().

◆ packInto() [2/2]

void Http::Message::packInto ( Packable p,
bool  full_uri 
) const

Definition at line 264 of file Message.cc.

References Packable::append().

◆ parse()

bool Http::Message::parse ( const char *  buf,
const size_t  sz,
bool  eol,
Http::StatusCode error 

◆ parseCharBuf()

bool Http::Message::parseCharBuf ( const char *  buf,
ssize_t  end 

parseCharBuf() takes character buffer of HTTP headers (buf), which may not be NULL-terminated, and fills in an Http::Message structure. The parameter 'end' specifies the offset to the end of the reply headers. The caller may know where the end is, but is unable to NULL-terminate the buffer. This function returns true on success.

Definition at line 140 of file Message.cc.

References MemBuf::append(), MemBuf::buf, MemBuf::clean(), MemBuf::init(), MemBuf::size, and MemBuf::terminate().

Referenced by store_client::readBody(), and urnHandleReply().

◆ parseFirstLine()

bool HttpReply::parseFirstLine ( const char *  start,
const char *  end 

Implements Http::Message.

Definition at line 454 of file HttpReply.cc.

References Http::StatusLine::parse(), protoPrefix, and sline.

◆ parseHeader() [1/2]

◆ parseHeader() [2/2]

bool HttpReply::parseHeader ( Http1::Parser hp)

◆ persistent()

bool Http::Message::persistent ( ) const
Return values
truethe message sender asks to keep the connection open.
falsethe message sender will close the connection.

Factors other than the headers may result in connection closure.

Definition at line 247 of file Message.cc.

References httpHeaderHasConnDir(), and Http::ProtocolVersion().

Referenced by clientReplyContext::buildReplyHeader(), clientSetKeepaliveFlag(), hdrCacheInit(), and HttpStateData::sendRequest().

◆ putCc()

void Http::Message::putCc ( const HttpHdrCc otherCc)

Definition at line 33 of file Message.cc.

References Http::CACHE_CONTROL.

Referenced by make304().

◆ receivedBodyTooLarge()

bool HttpReply::receivedBodyTooLarge ( HttpRequest request,
int64_t  receivedBodySize 

Checks whether received body exceeds known maximum size. Requires a prior call to calcMaxBodySize().

Definition at line 516 of file HttpReply.cc.

References bodySizeMax, calcMaxBodySize(), and debugs.

Referenced by clientReplyContext::replyStatus().

◆ recreateOnNotModified()

HttpReply::Pointer HttpReply::recreateOnNotModified ( const HttpReply reply304) const
nil (if no updates are necessary)
a new reply combining this reply with 304 updates (otherwise)

Definition at line 262 of file HttpReply.cc.

References clone(), HttpHeader::compact(), hdrCacheClean(), hdrCacheInit(), Http::Message::header, HttpHeader::needUpdate(), and HttpHeader::update().

Referenced by StoreEntry::updateOnNotModified().

◆ redirect()

◆ removeIrrelevantContentLength()

◆ reset()

void HttpReply::reset ( )

Implements Http::Message.

Definition at line 57 of file HttpReply.cc.

References clean(), init(), and protoPrefix.

Referenced by MemObject::reset(), and TestHttpReply::testSanityCheckFirstLine().

◆ sanityCheckStartLine()

bool HttpReply::sanityCheckStartLine ( const char *  buf,
const size_t  hdr_len,
Http::StatusCode error 

Checks the first line of an HTTP Reply is valid. currently only checks "HTTP/" exists.

NP: not all error cases are detected yet. Some are left for detection later in parse.

Implements Http::Message.

Definition at line 399 of file HttpReply.cc.

References String::cmp(), debugs, error(), protoPrefix, String::psize(), Http::scInvalidHeader, String::size(), and xisdigit.

Referenced by TestHttpReply::testSanityCheckFirstLine().

◆ setContentLength()

void Http::Message::setContentLength ( int64_t  clen)

Definition at line 239 of file Message.cc.

References Http::CONTENT_LENGTH.

◆ setHeaders()

◆ validatorsMatch()

int HttpReply::validatorsMatch ( HttpReply const *  other) const

Member Data Documentation

◆ body

HttpBody HttpReply::body

for small constant memory-resident text bodies only

Definition at line 58 of file HttpReply.h.

Referenced by ErrorState::BuildHttpReply(), clean(), ESIContext::fail(), packInto(), CacheManager::start(), and urnHandleReply().

◆ body_pipe

◆ bodySizeMax

int64_t HttpReply::bodySizeMax

cached result of calcMaxBodySize

Definition at line 150 of file HttpReply.h.

Referenced by calcMaxBodySize(), clean(), expectedBodyTooLarge(), and receivedBodyTooLarge().

◆ cache_control

◆ content_length

◆ content_range

HttpHdrContRange* HttpReply::content_range

Definition at line 152 of file HttpReply.h.

Referenced by contentRange(), hdrCacheClean(), and hdrCacheInit().

◆ content_type

String HttpReply::content_type

◆ date

time_t HttpReply::date

◆ do_clean

bool HttpReply::do_clean

Definition at line 62 of file HttpReply.h.

Referenced by ~HttpReply(), and init().

◆ expires

◆ hdr_sz

◆ header

HttpHeader Http::Message::header

Definition at line 74 of file Message.h.

Referenced by StoreEntry::adjustVary(), Ftp::Gateway::appendSuccessHeader(), Format::Format::assemble(), assembleVaryKey(), Auth::UserRequest::authenticate(), HttpStateData::blockSwitchingProtocols(), ConnStateData::buildFakeRequest(), ErrorState::BuildHttpReply(), Http::One::Server::buildHttpRequest(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), ESIVarState::buildVary(), HttpRequest::canHandle1xx(), HttpRequest::checkEntityFraming(), clean(), HttpRequest::clean(), ClientRequestContext::clientAccessCheck(), clientBeginRequest(), clientCheckPinning(), clientGetMoreData(), clientIfRangeMatch(), clientInterpretRequestHeaders(), clientPackRangeHdr(), clientProcessRequest(), Adaptation::Ecap::MessageRep::clone(), clone(), HttpRequest::clone(), ErrorState::compileLegacyCode(), HttpRequest::conditional(), Adaptation::Icap::Options::configure(), Ftp::Relay::createHttpReply(), ErrorState::Dump(), Adaptation::Icap::ModXact::encapsulateHead(), ESIContextNew(), Adaptation::Icap::ModXact::estimateVirginBody(), expectingBody(), HttpRequest::expectingBody(), Mgr::Action::fillEntry(), HttpStateData::forwardUpgrade(), Ftp::Gateway::ftpAuthRequired(), ftpSendStor(), Ssl::ErrorDetailsManager::getErrorDetail(), Ftp::Server::handleFeatReply(), Ftp::Server::handleRequest(), StoreEntry::hasIfMatchEtag(), StoreEntry::hasIfNoneMatchEtag(), StoreEntry::hasOneOfEtags(), HttpStateData::haveParsedReplyHeaders(), hdrCacheInit(), HttpRequest::hdrCacheInit(), hdrExpirationTime(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), HttpStateData::httpBuildRequestHeader(), Log::Format::HttpdCombined(), httpMakeVaryMark(), Ftp::HttpReplyWrapper(), Auth::SchemeConfig::isCP1251EncodingAllowed(), MimeIcon::load(), TemplateFile::loadFor(), Ftp::Gateway::loginFailed(), make304(), Adaptation::Icap::ModXact::makeRequestHeaders(), ACLReplyHeaderStrategy< header >::match(), ACLRequestHeaderStrategy< header >::match(), ACLHTTPRepHeaderStrategy::match(), ACLHTTPReqHeaderStrategy::match(), HttpRequest::pack(), packHeadersUsingFastPacker(), HttpRequest::parseHeader(), CacheManager::ParseHeaders(), Adaptation::Icap::OptXact::parseResponse(), peerDigestRequest(), HttpRequest::prefixLen(), prepareLogWithRequestDetails(), Adaptation::Icap::ModXact::prepEchoing(), Ftp::PrintReply(), clientReplyContext::processConditional(), clientReplyContext::processExpired(), Http::One::Server::processParsedRequest(), HttpStateData::processReplyHeader(), purgeEntriesByHeader(), recreateOnNotModified(), redirect(), removeIrrelevantContentLength(), HttpStateData::reusableReply(), Ftp::Server::setDataCommand(), setHeaders(), UrnState::setUriResFromRequest(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), CacheManager::start(), HttpStateData::statusIfComplete(), urlCheckRequest(), urnHandleReply(), Adaptation::Ecap::XactionRep::useAdapted(), Adaptation::Ecap::XactionRep::useVirgin(), validatorsMatch(), varyEvaluateMatch(), Http::One::Server::writeControlMsgAndCall(), Ftp::Server::writeCustomReply(), Ftp::Server::writeErrorReply(), Ftp::Server::writeForwardedReply(), and Ftp::Server::writeForwardedReplyAndCall().

◆ http_ver

◆ keep_alive

◆ last_modified

time_t HttpReply::last_modified

Definition at line 42 of file HttpReply.h.

Referenced by hdrCacheInit(), make304(), setHeaders(), storeLog(), and validatorsMatch().

◆ protoPrefix

◆ pstate

ParseState Http::Message::pstate = Http::Message::psReadyToParseStartLine

Definition at line 94 of file Message.h.

Referenced by clone(), HttpRequest::clone(), init(), and HttpRequest::init().

◆ sline

Http::StatusLine HttpReply::sline
public, writable, but use httpReply* interfaces when possible

Definition at line 56 of file HttpReply.h.

Referenced by ErrorState::ErrorState(), Auth::UserRequest::AddReplyAuthHeader(), asHandleReply(), bodySize(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), Adaptation::Icap::Launcher::canRepeat(), clean(), clone(), clientReplyContext::cloneReply(), FwdState::complete(), Adaptation::Icap::Options::configure(), configureContentLengthInterpreter(), contentRange(), Adaptation::Icap::ModXact::encapsulateHead(), esiBufferRecipient(), ESIContextNew(), expectingBody(), Adaptation::Icap::ModXact::finalizeLogInfo(), HttpStateData::handle1xx(), Ftp::Server::handleDataReply(), clientReplyContext::handleIMSReply(), Http::Tunneler::handleResponse(), HttpStateData::haveParsedReplyHeaders(), hdrCacheInit(), httpMsgParseError(), Ftp::HttpReplyWrapper(), init(), make304(), MakeConnectionEstablished(), Client::maybePurgeOthers(), netdbExchangeHandleReply(), packFirstLineInto(), packHeadersUsingFastPacker(), parseFirstLine(), peerDigestFetchReply(), peerDigestSwapInHeaders(), clientReplyContext::processConditional(), Http::One::Server::processParsedRequest(), clientReplyContext::processReplyAccess(), clientReplyContext::processReplyAccessResult(), HttpStateData::processReplyHeader(), redirect(), FwdState::reforward(), removeIrrelevantContentLength(), HttpStateData::reusableReply(), setHeaders(), clientReplyContext::setReplyToReply(), CacheManager::start(), storeLog(), urnHandleReply(), Http::One::Server::writeControlMsgAndCall(), and Ftp::Server::writeErrorReply().

◆ sources

◆ surrogate_control

HttpHdrSc* HttpReply::surrogate_control

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






Web Site Translations