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) ,
  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)
 
 ~Message () override
 
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 &)
 
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 86 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

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

◆ ~Message()

Http::Message::~Message ( )
override

Definition at line 27 of file Message.cc.

References assert.

Member Function Documentation

◆ clone()

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

Implemented in HttpReply, and HttpRequest.

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

◆ configureContentLengthInterpreter()

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

Implemented in HttpReply, and HttpRequest.

◆ expectingBody()

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

◆ firstLineBuf()

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

Definition at line 270 of file Message.cc.

◆ hdrCacheInit()

void Http::Message::hdrCacheInit ( )
protectedvirtual

Reimplemented in HttpReply, and HttpRequest.

Definition at line 261 of file Message.cc.

References assert, and Http::CONTENT_LENGTH.

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

◆ httpMsgParseError()

int Http::Message::httpMsgParseError ( )
virtual

Reimplemented in HttpReply.

Definition at line 221 of file Message.cc.

Referenced by HttpReply::httpMsgParseError().

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

References assert, httpMsgIsolateStart(), psParsed, psReadyToParseHeaders, and psReadyToParseStartLine.

◆ 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.

◆ packInto()

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

Definition at line 253 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 129 of file Message.cc.

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

◆ parseFirstLine()

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

Implemented in HttpReply, and HttpRequest.

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

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

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

◆ putCc()

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

copies Cache-Control header to this message, overwriting existing Cache-Control header(s), if any

Definition at line 33 of file Message.cc.

Referenced by HttpReply::make304(), and CacheManager::PutCommonResponseHeaders().

◆ 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. Zero hdr_len is treated as a serious problem.

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

Implemented in HttpReply, and HttpRequest.

◆ setContentLength()

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

Definition at line 228 of file Message.cc.

References Http::CONTENT_LENGTH.

Member Data Documentation

◆ body_pipe

◆ cache_control

◆ content_length

◆ 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(), HttpReply::clean(), HttpRequest::clean(), ClientRequestContext::clientAccessCheck(), clientBeginRequest(), clientCheckPinning(), clientGetMoreData(), clientIfRangeMatch(), clientInterpretRequestHeaders(), clientPackRangeHdr(), clientProcessRequest(), Adaptation::Ecap::MessageRep::clone(), HttpReply::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(), HttpReply::expectingBody(), HttpRequest::expectingBody(), Ssl::ErrorDetailsManager::findDetail(), HttpStateData::forwardUpgrade(), Ftp::Gateway::ftpAuthRequired(), ftpSendStor(), Ftp::Server::handleFeatReply(), Ftp::Server::handleRequest(), StoreEntry::hasIfMatchEtag(), StoreEntry::hasIfNoneMatchEtag(), StoreEntry::hasOneOfEtags(), HttpStateData::haveParsedReplyHeaders(), HttpReply::hdrCacheInit(), HttpRequest::hdrCacheInit(), HttpReply::hdrExpirationTime(), ClientRequestContext::hostHeaderVerify(), ClientRequestContext::hostHeaderVerifyFailed(), HttpStateData::httpBuildRequestHeader(), Log::Format::HttpdCombined(), httpMakeVaryMark(), Ftp::HttpReplyWrapper(), Auth::SchemeConfig::isCP1251EncodingAllowed(), MimeIcon::load(), TemplateFile::loadFor(), Ftp::Gateway::loginFailed(), HttpReply::make304(), Adaptation::Icap::ModXact::makeRequestHeaders(), HttpRequest::pack(), HttpReply::packHeadersUsingFastPacker(), HttpRequest::parseHeader(), CacheManager::ParseHeaders(), Adaptation::Icap::OptXact::parseResponse(), peerDigestRequest(), HttpReply::prefixLen(), HttpRequest::prefixLen(), prepareLogWithRequestDetails(), Adaptation::Icap::ModXact::prepEchoing(), Ftp::PrintReply(), clientReplyContext::processConditional(), clientReplyContext::processExpired(), Http::One::Server::processParsedRequest(), HttpStateData::processReplyHeader(), purgeEntriesByHeader(), CacheManager::PutCommonResponseHeaders(), HttpReply::recreateOnNotModified(), HttpReply::redirect(), HttpReply::removeIrrelevantContentLength(), HttpStateData::reusableReply(), Ftp::Server::setDataCommand(), HttpReply::setHeaders(), UrnState::setUriResFromRequest(), Log::Format::SquidReferer(), Log::Format::SquidUserAgent(), CacheManager::start(), HttpStateData::statusIfComplete(), 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().

◆ http_ver

◆ pstate

◆ sources


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors