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 ()
 
bool parseHeader (Http1::Parser &)
 
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 ()
 

Detailed Description

Definition at line 24 of file Message.h.

Member Enumeration Documentation

Enumerator
psReadyToParseStartLine 
psReadyToParseHeaders 
psParsed 
psError 

Definition at line 86 of file Message.h.

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

Http::Message::Message ( http_hdr_owner_type  owner)

Definition at line 22 of file Message.cc.

Http::Message::~Message ( )
virtual

Definition at line 27 of file Message.cc.

References assert.

Member Function Documentation

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

Implemented in HttpReply, and HttpRequest.

Referenced by Adaptation::Message::ShortCircuit().

virtual bool Http::Message::expectingBody ( const HttpRequestMethod ,
int64_t &   
) const
pure virtual
void Http::Message::firstLineBuf ( MemBuf mb)

Definition at line 291 of file Message.cc.

void Http::Message::hdrCacheInit ( )
protectedvirtual

Reimplemented in HttpRequest, and HttpReply.

Definition at line 282 of file Message.cc.

References assert, Http::CONTENT_LENGTH, and NULL.

Referenced by HttpReply::hdrCacheInit(), and HttpRequest::hdrCacheInit().

int Http::Message::httpMsgParseError ( )
virtual

Reimplemented in HttpReply.

Definition at line 242 of file Message.cc.

Referenced by HttpReply::httpMsgParseError().

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

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

Referenced by MemStore::copyFromShmSlice().

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

Implemented in HttpRequest, and HttpReply.

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

Definition at line 274 of file Message.cc.

References Packable::append().

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

bool Http::Message::parse ( const char *  buf,
const size_t  sz,
bool  eol,
Http::StatusCode error 
)
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 147 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().

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

Implemented in HttpRequest, and HttpReply.

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

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

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

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

Definition at line 33 of file Message.cc.

References Http::CACHE_CONTROL.

Referenced by HttpReply::make304().

virtual void Http::Message::reset ( )
pure virtual
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.

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

Definition at line 249 of file Message.cc.

References Http::CONTENT_LENGTH.

Member Data Documentation

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(), ConnStateData::buildFakeRequest(), ErrorState::BuildHttpReply(), Http::One::Server::buildHttpRequest(), Http::Stream::buildRangeHeader(), clientReplyContext::buildReplyHeader(), Downloader::buildRequest(), ESIVarState::buildVary(), HttpRequest::canHandle1xx(), htcpSpecifier::checkHit(), HttpRequest::clean(), HttpReply::clean(), ClientRequestContext::clientAccessCheck(), clientBeginRequest(), clientCheckPinning(), clientGetMoreData(), clientIfRangeMatch(), clientInterpretRequestHeaders(), clientIsContentLengthValid(), clientProcessRequest(), HttpRequest::clone(), HttpReply::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(), HttpReply::expectingBody(), HttpRequest::expectingBody(), Mgr::Action::fillEntry(), Adaptation::Icap::ModXact::finalizeLogInfo(), Ftp::Gateway::ftpAuthRequired(), ftpSendStor(), Ssl::ErrorDetailsManager::getErrorDetail(), gopherMimeCreate(), Ftp::Server::handleFeatReply(), Ftp::Server::handleRequest(), StoreEntry::hasIfMatchEtag(), StoreEntry::hasIfNoneMatchEtag(), StoreEntry::hasOneOfEtags(), HttpReply::hdrCacheInit(), HttpRequest::hdrCacheInit(), HttpReply::hdrExpirationTime(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), htcpClrStore(), HttpStateData::httpBuildRequestHeader(), Log::Format::HttpdCombined(), httpMakeVaryMark(), Ftp::HttpReplyWrapper(), TemplateFile::loadFor(), Ftp::Gateway::loginFailed(), HttpReply::make304(), Adaptation::Icap::ModXact::makeRequestHeaders(), ACLHTTPReqHeaderStrategy::match(), ACLHTTPRepHeaderStrategy::match(), ACLRequestHeaderStrategy< header >::match(), ACLReplyHeaderStrategy< header >::match(), HttpRequest::pack(), HttpReply::packHeadersInto(), 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(), HttpReply::redirect(), HttpReply::removeStaleWarnings(), HttpStateData::reusableReply(), Ftp::Server::setDataCommand(), HttpReply::setHeaders(), UrnState::setUriResFromRequest(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), Mgr::Inquirer::start(), CacheManager::Start(), HttpStateData::statusIfComplete(), StoreEntry::timestampsSet(), HttpReply::updateOnNotModified(), urlCheckRequest(), Adaptation::Ecap::XactionRep::useAdapted(), Adaptation::Ecap::XactionRep::useVirgin(), HttpReply::validatorsMatch(), varyEvaluateMatch(), Http::One::Server::writeControlMsgAndCall(), Ftp::Server::writeCustomReply(), Ftp::Server::writeErrorReply(), Ftp::Server::writeForwardedReply(), and Ftp::Server::writeForwardedReplyAndCall().


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors