common parts of HttpRequest and HttpReply More...

#include <Message.h>

Inheritance diagram for Http::Message:
Collaboration diagram for Http::Message:

Public Types

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

 Message (http_hdr_owner_type)
 
virtual ~Message ()
 
virtual void reset ()=0
 
void packInto (Packable *, bool full_uri) const
 produce a message copy, except for a few connection-specific settings More...
 
virtual Http::Messageclone () const =0
 
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)
 
virtual int httpMsgParseError ()
 
virtual bool expectingBody (const HttpRequestMethod &, int64_t &) const =0
 
void firstLineBuf (MemBuf &)
 useful for debugging More...
 
virtual bool inheritProperties (const Http::Message *)=0
 

Public Attributes

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 bool sanityCheckStartLine (const char *buf, const size_t hdr_len, Http::StatusCode *error)=0
 
virtual void packFirstLineInto (Packable *p, bool full_uri) const =0
 
virtual bool parseFirstLine (const char *blk_start, const char *blk_end)=0
 
virtual void hdrCacheInit ()
 
virtual void configureContentLengthInterpreter (Http::ContentLengthInterpreter &)=0
 configures the interpreter as needed More...
 
bool parseHeader (Http1::Parser &, Http::ContentLengthInterpreter &)
 

Detailed Description

Definition at line 25 of file Message.h.

Member Enumeration Documentation

◆ ParseState

Enumerator
psReadyToParseStartLine 
psReadyToParseHeaders 
psParsed 
psError 

Definition at line 87 of file Message.h.

◆ Sources

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 29 of file Message.h.

Constructor & Destructor Documentation

◆ Message()

Http::Message::Message ( http_hdr_owner_type  owner)

Definition at line 23 of file Message.cc.

◆ ~Message()

Http::Message::~Message ( )
virtual

Definition at line 28 of file Message.cc.

References assert, and body_pipe.

Member Function Documentation

◆ clone()

virtual Http::Message* Http::Message::clone ( ) const
pure virtual

◆ configureContentLengthInterpreter()

virtual void Http::Message::configureContentLengthInterpreter ( Http::ContentLengthInterpreter )
protectedpure virtual

Implemented in HttpRequest, and HttpReply.

Referenced by httpMsgParseStep(), and parseHeader().

◆ expectingBody()

virtual bool Http::Message::expectingBody ( const HttpRequestMethod ,
int64_t &   
) const
pure virtual

◆ firstLineBuf()

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

Definition at line 295 of file Message.cc.

References packFirstLineInto().

◆ hdrCacheInit()

void Http::Message::hdrCacheInit ( )
protectedvirtual

◆ httpMsgParseError()

int Http::Message::httpMsgParseError ( )
virtual

Reimplemented in HttpReply.

Definition at line 246 of file Message.cc.

References reset().

Referenced by HttpReply::httpMsgParseError(), and httpMsgParseStep().

◆ httpMsgParseStep()

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

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, configureContentLengthInterpreter(), hdr_sz, hdrCacheInit(), header, httpMsgIsolateStart(), httpMsgParseError(), len, HttpHeader::parse(), parseFirstLine(), PROF_start, PROF_stop, psParsed, psReadyToParseHeaders, psReadyToParseStartLine, and pstate.

Referenced by MemStore::copyFromShmSlice(), parse(), and parseCharBuf().

◆ inheritProperties()

virtual bool Http::Message::inheritProperties ( const Http::Message )
pure virtual

◆ packFirstLineInto()

virtual void Http::Message::packFirstLineInto ( Packable p,
bool  full_uri 
) const
protectedpure virtual

Implemented in HttpRequest, and HttpReply.

Referenced by firstLineBuf(), and packInto().

◆ packInto()

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

◆ parse()

◆ 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 148 of file Message.cc.

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

Referenced by Adaptation::Icap::ModXact::makeRequestHeaders(), store_client::readBody(), and urnHandleReply().

◆ parseFirstLine()

virtual bool Http::Message::parseFirstLine ( const char *  blk_start,
const char *  blk_end 
)
protectedpure virtual

Implemented in HttpRequest, and HttpReply.

Referenced by httpMsgParseStep().

◆ parseHeader()

◆ 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 261 of file Message.cc.

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

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

◆ putCc()

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

◆ reset()

virtual void Http::Message::reset ( )
pure virtual

◆ sanityCheckStartLine()

virtual bool Http::Message::sanityCheckStartLine ( const char *  buf,
const size_t  hdr_len,
Http::StatusCode error 
)
protectedpure virtual

Validate the message start line is syntactically correct. Set HTTP error status according to problems found.

Return values
trueStatus line has no serious problems.
falseStatus line has a serious problem. Correct response is indicated by error.

Implemented in HttpRequest, and HttpReply.

Referenced by parse().

◆ setContentLength()

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

Member Data Documentation

◆ body_pipe

◆ cache_control

◆ content_length

◆ hdr_sz

◆ header

HttpHeader Http::Message::header

Definition at line 75 of file Message.h.

Referenced by StoreEntry::adjustVary(), Ftp::Gateway::appendSuccessHeader(), Format::Format::assemble(), assembleVaryKey(), authDigestNoncePurge(), Auth::UserRequest::authenticate(), ConnStateData::buildFakeRequest(), ErrorState::BuildHttpReply(), Http::One::Server::buildHttpRequest(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), Downloader::buildRequest(), ESIVarState::buildVary(), HttpRequest::canHandle1xx(), HttpRequest::clean(), HttpReply::clean(), clientBeginRequest(), clientCheckPinning(), clientGetMoreData(), clientIfRangeMatch(), clientInterpretRequestHeaders(), clientIsContentLengthValid(), clientProcessRequest(), HttpRequest::clone(), HttpReply::clone(), ErrorState::compileLegacyCode(), HttpRequest::conditional(), Adaptation::Icap::Options::configure(), MimeIcon::created(), Ftp::Relay::createHttpReply(), ErrorState::Dump(), Adaptation::Icap::ModXact::encapsulateHead(), ESIContextNew(), Adaptation::Icap::ModXact::expectIcapTrailers(), HttpReply::expectingBody(), HttpRequest::expectingBody(), Mgr::Action::fillEntry(), Adaptation::Icap::ModXact::finalizeLogInfo(), Ftp::Gateway::ftpAuthRequired(), ftpSendStor(), Ssl::ErrorDetailsManager::getErrorDetail(), Adaptation::Icap::ModXact::gotEncapsulated(), Adaptation::Icap::OptXact::handleCommRead(), Ftp::Server::handleFeatReply(), Ftp::Server::handleRequest(), StoreEntry::hasIfMatchEtag(), StoreEntry::hasIfNoneMatchEtag(), StoreEntry::hasOneOfEtags(), HttpReply::hdrCacheInit(), hdrCacheInit(), HttpRequest::hdrCacheInit(), HttpReply::hdrExpirationTime(), HttpStateData::httpBuildRequestHeader(), Log::Format::HttpdCombined(), httpMakeVaryMark(), httpMsgParseStep(), Ftp::HttpReplyWrapper(), TemplateFile::loadFor(), Ftp::Gateway::loginFailed(), HttpReply::make304(), Adaptation::Icap::ModXact::makeRequestHeaders(), ACLHTTPReqHeaderStrategy::match(), ACLHTTPRepHeaderStrategy::match(), ACLRequestHeaderStrategy< header >::match(), ACLReplyHeaderStrategy< header >::match(), mcast_encode(), HttpRequest::pack(), HttpReply::packHeadersUsingFastPacker(), packInto(), parseHeader(), HttpRequest::parseHeader(), CacheManager::ParseHeaders(), Adaptation::Icap::ModXact::parseIcapHead(), Ftp::Server::parseOneRequest(), Adaptation::Icap::OptXact::parseResponse(), peerDigestRequest(), persistent(), HttpRequest::prefixLen(), prepareLogWithRequestDetails(), Ftp::PrintReply(), clientReplyContext::processConditional(), clientReplyContext::processExpired(), Http::One::Server::processParsedRequest(), HttpStateData::processReplyHeader(), purgeEntriesByHeader(), putCc(), HttpReply::redirect(), HttpReply::removeIrrelevantContentLength(), HttpReply::removeStaleWarnings(), HttpStateData::reusableReply(), Ftp::Relay::sendCommand(), setContentLength(), Ftp::Server::setDataCommand(), HttpReply::setHeaders(), UrnState::setUriResFromRequest(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), Mgr::Inquirer::start(), CacheManager::start(), Ftp::Gateway::start(), HttpStateData::statusIfComplete(), StoreEntry::timestampsSet(), HttpReply::updateOnNotModified(), urlCheckRequest(), HttpReply::validatorsMatch(), varyEvaluateMatch(), Http::One::Server::writeControlMsgAndCall(), Ftp::Server::writeCustomReply(), Ftp::Server::writeErrorReply(), Ftp::Server::writeForwardedReply(), and Ftp::Server::writeForwardedReplyAndCall().

◆ http_ver

◆ pstate

◆ sources


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors