#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),
  srcGopher = 1 << (16 + 14),
  srcWhois = 1 << (16 + 15),
  srcUnsafe = 0xFFFF0000,
  srcSafe = 0x0000FFFF
}
 Who may have created or modified this message? More...
 
enum  ParseState {
  psReadyToParseStartLine = 0,
  psReadyToParseHeaders,
  psParsed,
  psError
}
 parse state of HttpReply or HttpRequest More...
 

Public Member Functions

void * operator new (size_t byteCount)
 
void operator delete (void *address)
 
 HttpReply ()
 
 ~HttpReply ()
 
virtual void reset ()
 
virtual bool sanityCheckStartLine (const char *buf, const size_t hdr_len, Http::StatusCode *error)
 
const HttpHdrContRangecontentRange () const
 
virtual int httpMsgParseError ()
 
virtual bool expectingBody (const HttpRequestMethod &, int64_t &) const
 
virtual bool inheritProperties (const Http::Message *)
 
bool updateOnNotModified (HttpReply const *other)
 
void setHeaders (Http::StatusCode status, const char *reason, const char *ctype, int64_t clen, time_t lmt, time_t expires)
 
MemBufpack () const
 
HttpReplymake304 () 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
 
void removeStaleWarnings ()
 Remove Warnings with warn-date different from Date value. More...
 
virtual void hdrCacheInit ()
 
bool olderThan (const HttpReply *them) const
 
void removeIrrelevantContentLength ()
 Some response status codes prohibit sending Content-Length (RFC 7230 section 3.3.2). More...
 
virtual void configureContentLengthInterpreter (Http::ContentLengthInterpreter &)
 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 int UseCount ()
 

Public Attributes

time_t date
 
time_t last_modified
 
time_t expires
 
String content_type
 
HttpHdrScsurrogate_control
 
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

virtual void packFirstLineInto (Packable *p, bool) const
 
virtual bool parseFirstLine (const char *start, const char *end)
 
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
 
String removeStaleWarningValues (const String &value)
 

Static Private Member Functions

static Mem::AllocatorProxyPool ()
 

Private Attributes

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

Detailed Description

Definition at line 24 of file HttpReply.h.

Member Typedef Documentation

Definition at line 26 of file HttpReply.h.

Member Enumeration Documentation

enum Http::Message::ParseState
inherited
Enumerator
psReadyToParseStartLine 
psReadyToParseHeaders 
psParsed 
psError 

Definition at line 86 of file Message.h.

enum Http::Message::Sources
inherited
Enumerator
srcUnknown 
srcHttps 

https_port or bumped http_port tunnel; HTTPS server

srcFtps 

ftps_port or SFTP server; currently unused

srcIcaps 

Secure ICAP service.

srcEcaps 

eCAP service that is considered secure; currently unused

srcHttp 

http_port or HTTP server

srcFtp 

ftp_port or FTP server

srcIcap 

traditional ICAP service without encryption

srcEcap 

eCAP service that uses insecure libraries/daemons

srcGopher 

Gopher server.

srcWhois 

Whois server.

srcUnsafe 

Unsafe sources mask.

srcSafe 

Safe sources mask.

Definition at line 28 of file Message.h.

Constructor & Destructor Documentation

HttpReply::HttpReply ( )

Definition at line 29 of file HttpReply.cc.

References init().

Referenced by clone(), and make304().

HttpReply::~HttpReply ( )

Definition at line 43 of file HttpReply.cc.

References clean(), and do_clean.

Member Function Documentation

void HttpReply::calcMaxBodySize ( HttpRequest request) const
private
void HttpReply::clean ( )
private
HttpReply * HttpReply::clone ( ) const
virtual

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

Implements Http::Message.

Definition at line 568 of file HttpReply.cc.

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

Referenced by clientReplyContext::cloneReply().

void HttpReply::configureContentLengthInterpreter ( Http::ContentLengthInterpreter )
virtual
const HttpHdrContRange * HttpReply::contentRange ( ) const
Returns
parsed Content-Range for a 206 response and nil for others

Definition at line 339 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().

bool HttpReply::expectedBodyTooLarge ( HttpRequest request)

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

Definition at line 520 of file HttpReply.cc.

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

Referenced by clientReplyContext::processReplyAccess().

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

Definition at line 295 of file Message.cc.

void HttpReply::hdrCacheClean ( )
private
int HttpReply::httpMsgParseError ( )
virtual
int Http::Message::httpMsgParseStep ( const char *  buf,
int  len,
int  atEnd 
)
inherited

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

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

Definition at line 170 of file Message.cc.

References assert, buf, httpMsgIsolateStart(), len, PROF_start, PROF_stop, Http::Message::psParsed, Http::Message::psReadyToParseHeaders, and Http::Message::psReadyToParseStartLine.

Referenced by MemStore::copyFromShmSlice().

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

Implements Http::Message.

Definition at line 584 of file HttpReply.cc.

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

void HttpReply::init ( void  )
private
bool HttpReply::olderThan ( const HttpReply them) const

whether our Date header value is smaller than theirs

Returns
false if any information is missing

Definition at line 659 of file HttpReply.cc.

References date.

Referenced by clientReplyContext::handleIMSReply().

void HttpReply::operator delete ( void *  address)
inline

Definition at line 26 of file HttpReply.h.

void* HttpReply::operator new ( size_t  byteCount)
inline

Definition at line 26 of file HttpReply.h.

MemBuf * HttpReply::pack ( ) const
Returns
a ready to use mem buffer with a packed reply

Definition at line 111 of file HttpReply.cc.

References MemBuf::init(), and packInto().

Referenced by packed304Reply(), Http::Stream::sendStartOfMessage(), Mgr::Inquirer::start(), and Http::One::Server::writeControlMsgAndCall().

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

Definition at line 149 of file HttpReply.cc.

References make304(), and pack().

virtual void HttpReply::packFirstLineInto ( Packable p,
bool   
) const
inlineprotectedvirtual

Implements Http::Message.

Definition at line 159 of file HttpReply.h.

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

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 86 of file HttpReply.cc.

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

Referenced by packHeadersUsingSlowPacker(), and packInto().

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

Definition at line 278 of file Message.cc.

References Packable::append().

Referenced by Adaptation::Icap::ModXact::packHead().

void HttpReply::packInto ( MemBuf buf) const
private

Definition at line 103 of file HttpReply.cc.

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

Referenced by pack().

bool Http::Message::parse ( const char *  buf,
const size_t  sz,
bool  eol,
Http::StatusCode error 
)
inherited
bool Http::Message::parseCharBuf ( const char *  buf,
ssize_t  end 
)
inherited

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 148 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().

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

Implements Http::Message.

Definition at line 451 of file HttpReply.cc.

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

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

Definition at line 463 of file HttpReply.cc.

Referenced by HttpStateData::processReplyHeader().

bool Http::Message::persistent ( ) const
inherited
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 261 of file Message.cc.

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

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

static Mem::AllocatorProxy& HttpReply::Pool ( )
inlinestaticprivate

Definition at line 26 of file HttpReply.h.

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

Definition at line 34 of file Message.cc.

References Http::CACHE_CONTROL.

Referenced by make304().

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 512 of file HttpReply.cc.

References bodySizeMax, calcMaxBodySize(), debugs, and HERE().

Referenced by clientReplyContext::replyStatus().

String HttpReply::removeStaleWarningValues ( const String value)
private

Remove warning-values with warn-date different from Date value from a single header entry. Returns a string with all valid warning-values.

Definition at line 614 of file HttpReply.cc.

References String::append(), date, len, p, parse_rfc1123(), String::size(), strListGetItem(), String::termedBuf(), and xisspace.

Referenced by removeStaleWarnings().

void HttpReply::reset ( )
virtual

Implements Http::Message.

Definition at line 58 of file HttpReply.cc.

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

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

bool HttpReply::sanityCheckStartLine ( const char *  buf,
const size_t  hdr_len,
Http::StatusCode error 
)
virtual
Return values
trueon success
falseand sets *error to zero when needs more data
falseand sets *error to a positive Http::StatusCode on 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 396 of file HttpReply.cc.

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

Referenced by testHttpReply::testSanityCheckFirstLine().

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

Definition at line 253 of file Message.cc.

References Http::CONTENT_LENGTH.

bool HttpReply::updateOnNotModified ( HttpReply const *  other)
static int HttpReply::UseCount ( )
inlinestatic

Definition at line 26 of file HttpReply.h.

Member Data Documentation

HttpBody HttpReply::body

for small constant memory-resident text bodies only

Definition at line 62 of file HttpReply.h.

Referenced by ErrorState::BuildHttpReply(), clean(), ESIContext::fail(), packInto(), and StoreEntry::startWriting().

int64_t HttpReply::bodySizeMax
mutableprivate

cached result of calcMaxBodySize

Definition at line 154 of file HttpReply.h.

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

HttpHdrContRange* HttpReply::content_range
private

Definition at line 156 of file HttpReply.h.

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

time_t HttpReply::date
bool HttpReply::do_clean

Definition at line 66 of file HttpReply.h.

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

HttpHeader Http::Message::header
inherited

Definition at line 74 of file Message.h.

Referenced by StoreEntry::adjustVary(), Ftp::Gateway::appendSuccessHeader(), Format::Format::assemble(), assembleVaryKey(), Auth::UserRequest::authenticate(), ConnStateData::buildFakeRequest(), ErrorState::BuildHttpReply(), Http::One::Server::buildHttpRequest(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), Downloader::buildRequest(), ESIVarState::buildVary(), HttpRequest::canHandle1xx(), HttpRequest::clean(), clean(), ClientRequestContext::clientAccessCheck(), clientBeginRequest(), clientCheckPinning(), clientGetMoreData(), clientIfRangeMatch(), clientInterpretRequestHeaders(), clientIsContentLengthValid(), clientProcessRequest(), HttpRequest::clone(), clone(), Adaptation::Ecap::MessageRep::clone(), HttpRequest::conditional(), Adaptation::Icap::Options::configure(), ErrorState::Convert(), MimeIcon::created(), Ftp::Relay::createHttpReply(), ErrorState::Dump(), Adaptation::Icap::ModXact::encapsulateHead(), ESIContextNew(), Adaptation::Icap::ModXact::estimateVirginBody(), expectingBody(), HttpRequest::expectingBody(), Mgr::Action::fillEntry(), Adaptation::Icap::ModXact::finalizeLogInfo(), Ftp::Gateway::ftpAuthRequired(), ftpSendStor(), Ssl::ErrorDetailsManager::getErrorDetail(), Ftp::Server::handleFeatReply(), Ftp::Server::handleRequest(), StoreEntry::hasIfMatchEtag(), StoreEntry::hasIfNoneMatchEtag(), StoreEntry::hasOneOfEtags(), hdrCacheInit(), HttpRequest::hdrCacheInit(), hdrExpirationTime(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), HttpStateData::httpBuildRequestHeader(), Log::Format::HttpdCombined(), httpMakeVaryMark(), Ftp::HttpReplyWrapper(), TemplateFile::loadFor(), Ftp::Gateway::loginFailed(), make304(), Adaptation::Icap::ModXact::makeRequestHeaders(), ACLHTTPReqHeaderStrategy::match(), ACLHTTPRepHeaderStrategy::match(), ACLRequestHeaderStrategy< header >::match(), ACLReplyHeaderStrategy< header >::match(), HttpRequest::pack(), packHeadersUsingFastPacker(), HttpRequest::parseHeader(), CacheManager::ParseHeaders(), Ftp::Server::parseOneRequest(), 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(), redirect(), removeIrrelevantContentLength(), removeStaleWarnings(), HttpStateData::reusableReply(), Ftp::Server::setDataCommand(), setHeaders(), UrnState::setUriResFromRequest(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), Mgr::Inquirer::start(), CacheManager::Start(), HttpStateData::statusIfComplete(), StoreEntry::timestampsSet(), updateOnNotModified(), urlCheckRequest(), 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().

time_t HttpReply::last_modified
ParseState Http::Message::pstate = Http::Message::psReadyToParseStartLine
inherited
Http::StatusLine HttpReply::sline
public, writable, but use httpReply* interfaces when possible

Definition at line 60 of file HttpReply.h.

Referenced by 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(), TunnelStateData::handleConnectResponse(), Ftp::Server::handleDataReply(), clientReplyContext::handleIMSReply(), HttpStateData::handleMoreRequestBodyAvailable(), hdrCacheInit(), httpMsgParseError(), Ftp::HttpReplyWrapper(), init(), ClientHttpRequest::logRequest(), make304(), Client::maybePurgeOthers(), netdbExchangeHandleReply(), packFirstLineInto(), packHeadersUsingFastPacker(), parseFirstLine(), peerDigestFetchReply(), peerDigestSwapInHeaders(), clientReplyContext::processConditional(), Http::One::Server::processParsedRequest(), clientReplyContext::processReplyAccess(), clientReplyContext::processReplyAccessResult(), HttpStateData::processReplyHeader(), store_client::readBody(), redirect(), FwdState::reforward(), removeIrrelevantContentLength(), HttpStateData::reusableReply(), setHeaders(), clientReplyContext::setReplyToReply(), CacheManager::Start(), storeLog(), StoreEntry::validLength(), and Ftp::Server::writeErrorReply().

HttpHdrSc* HttpReply::surrogate_control

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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors