common parts of HttpRequest and HttpReply More...
#include <Message.h>
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::Message * | clone () 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 |
HttpHdrCc * | cache_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
Member Enumeration Documentation
◆ ParseState
◆ Sources
Constructor & Destructor Documentation
◆ Message()
Http::Message::Message | ( | http_hdr_owner_type | owner | ) |
Definition at line 22 of file Message.cc.
◆ ~Message()
|
override |
Definition at line 27 of file Message.cc.
References assert.
Member Function Documentation
◆ clone()
|
pure virtual |
Implemented in HttpReply, and HttpRequest.
Referenced by Adaptation::Message::ShortCircuit().
◆ configureContentLengthInterpreter()
|
protectedpure virtual |
Implemented in HttpReply, and HttpRequest.
◆ expectingBody()
|
pure virtual |
Implemented in HttpReply, and HttpRequest.
Referenced by Adaptation::Icap::ModXact::estimateVirginBody().
◆ firstLineBuf()
void Http::Message::firstLineBuf | ( | MemBuf & | mb | ) |
Definition at line 270 of file Message.cc.
◆ 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()
|
virtual |
Reimplemented in HttpReply.
Definition at line 221 of file Message.cc.
Referenced by HttpReply::httpMsgParseError().
◆ httpMsgParseStep()
parses a 0-terminated buffer into Http::Message.
- Return values
-
1 success 0 need more data (partial parse) -1 parse error
Definition at line 151 of file Message.cc.
References assert, httpMsgIsolateStart(), psParsed, psReadyToParseHeaders, and psReadyToParseStartLine.
◆ inheritProperties()
|
pure virtual |
Implemented in HttpReply, and HttpRequest.
Referenced by Adaptation::Icap::ModXact::encapsulateHead(), and Adaptation::Icap::ModXact::prepEchoing().
◆ packFirstLineInto()
|
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 | ||
) |
Definition at line 68 of file Message.cc.
References assert, Config, DBG_IMPORTANT, debugs, error(), headersEnd(), int, SquidConfig::maxReplyHeaderSize, Http::scHeaderTooLarge, Http::scInvalidHeader, and Http::scNone.
Referenced by Adaptation::Icap::Xaction::parseHttpMsg(), and HttpReply::parseTerminatedPrefix().
◆ 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()
|
protectedpure virtual |
Implemented in HttpReply, and HttpRequest.
◆ parseHeader()
|
protected |
Definition at line 201 of file Message.cc.
References SBuf::c_str(), Http::One::Parser::headerBlockSize(), Http::One::Parser::messageHeaderSize(), Http::One::Parser::mimeHeader(), psError, and psParsed.
◆ persistent()
bool Http::Message::persistent | ( | ) | const |
- Return values
-
true the message sender asks to keep the connection open. false the 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()
|
pure virtual |
Implemented in HttpReply, and HttpRequest.
Referenced by Adaptation::Icap::Xaction::parseHttpMsg().
◆ sanityCheckStartLine()
|
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
-
true Status line has no serious problems. false Status 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
BodyPipe::Pointer Http::Message::body_pipe |
Definition at line 97 of file Message.h.
Referenced by HttpRequest::bodyNibbled(), FwdState::checkRetriable(), HttpReply::clean(), HttpRequest::clean(), clientProcessRequest(), ClientRequestContext::clientRedirectDone(), Adaptation::Ecap::MessageRep::clone(), HttpReply::clone(), HttpRequest::clone(), FwdState::doneWithRetries(), Adaptation::Icap::ModXact::estimateVirginBody(), Adaptation::Icap::ModXact::finalizeLogInfo(), ClientHttpRequest::handleAdaptationFailure(), Client::handleAdaptedHeader(), HttpRequest::init(), ClientHttpRequest::logRequest(), Adaptation::Icap::ModXact::prepEchoing(), HttpStateData::sendRequest(), Adaptation::Icap::InOut::setHeader(), Adaptation::Message::ShortCircuit(), Client::startAdaptation(), Client::startRequestBodyFlow(), Adaptation::Ecap::XactionRep::useAdapted(), and Adaptation::Ecap::XactionRep::useVirgin().
◆ cache_control
HttpHdrCc* Http::Message::cache_control = nullptr |
Definition at line 76 of file Message.h.
Referenced by HttpRequest::clean(), clientInterpretRequestHeaders(), HttpStateData::haveParsedReplyHeaders(), HttpReply::hdrCacheClean(), HttpReply::hdrExpirationTime(), MimeIcon::load(), HttpReply::make304(), HttpRequest::maybeCacheable(), ClientHttpRequest::onlyIfCached(), refreshCheck(), and HttpStateData::reusableReply().
◆ content_length
int64_t Http::Message::content_length = 0 |
Definition at line 83 of file Message.h.
Referenced by HttpReply::bodySize(), Http::Stream::buildRangeHeader(), HttpHdrRange::canonize(), HttpRequest::checkEntityFraming(), StoreEntry::checkTooBig(), StoreEntry::checkTooSmall(), clientBeginRequest(), clientPackRangeHdr(), clientProcessRequest(), HttpReply::expectingBody(), HttpRequest::expectingBody(), Downloader::handleReply(), HttpReply::hdrCacheInit(), HttpStateData::persistentConnStatus(), HttpReply::redirect(), refreshIsCachable(), HttpStateData::sendRequest(), HttpReply::setHeaders(), storeLog(), clientReplyContext::storeNotOKTransferDone(), HttpStateData::truncateVirginBody(), and HttpReply::validatorsMatch().
◆ hdr_sz
int Http::Message::hdr_sz = 0 |
Definition at line 81 of file Message.h.
Referenced by StoreEntry::append(), HttpReply::clone(), HttpRequest::clone(), StoreEntry::contentLen(), store_client::doCopy(), MemObject::expectedReplySize(), Adaptation::Icap::ModXact::finalizeLogInfo(), Http::Tunneler::handleResponse(), MemObject::markEndOfReplyHeaders(), store_client::nextHttpReadOffset(), Adaptation::Icap::Xaction::parseHttpMsg(), HttpReply::parseTerminatedPrefix(), clientReplyContext::processReplyAccessResult(), MemObject::readAheadPolicyCanRead(), store_client::sendingHttpHeaders(), store_client::skipHttpHeadersFromDisk(), clientReplyContext::storeOKTransferDone(), MemStore::updateHeadersOrThrow(), and StoreEntry::write().
◆ 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
AnyP::ProtocolVersion Http::Message::http_ver |
HTTP-Version field in the first line of the message. see RFC 7230 section 3.1
Definition at line 72 of file Message.h.
Referenced by netdbExchangeState::netdbExchangeState(), Format::Format::assemble(), ErrorState::BuildHttpReply(), clientReplyContext::buildReplyHeader(), HttpRequest::canHandle1xx(), HttpRequest::checkEntityFraming(), clientBeginRequest(), clientProcessRequest(), ClientRequestContext::clientRedirectDone(), clientSetKeepaliveFlag(), HttpReply::clone(), HttpRequest::clone(), ErrorState::compileLegacyCode(), ErrorState::Dump(), Adaptation::Icap::ModXact::encapsulateHead(), HttpStateData::forwardUpgrade(), HttpReply::hdrCacheInit(), htcpClear(), htcpQuery(), HttpStateData::httpBuildRequestHeader(), HttpRequest::pack(), HttpRequest::packFirstLineInto(), HttpRequest::parseFirstLine(), prepareLogWithRequestDetails(), switchToTunnel(), and tunnelStart().
◆ pstate
ParseState Http::Message::pstate = Http::Message::psReadyToParseStartLine |
Definition at line 94 of file Message.h.
Referenced by HttpReply::clone(), HttpRequest::clone(), MemStore::copyFromShm(), store_client::handleBodyFromDisk(), HttpReply::init(), HttpRequest::init(), HttpReply::parseTerminatedPrefix(), and clientReplyContext::storeNotOKTransferDone().
◆ sources
uint32_t Http::Message::sources = 0 |
Definition at line 99 of file Message.h.
Referenced by Ftp::Gateway::appendSuccessHeader(), ConnStateData::buildFakeRequest(), clientProcessRequest(), Ftp::Relay::forwardReply(), Http::Tunneler::handleResponse(), HttpReply::inheritProperties(), HttpRequest::inheritProperties(), Acl::ConnectionsEncrypted::match(), HttpStateData::processReplyHeader(), WhoisState::setReplyToOK(), Ftp::Relay::startDataDownload(), and Adaptation::Ecap::XactionRep::updateSources().
The documentation for this class was generated from the following files:
- src/http/Message.h
- src/http/Message.cc
- src/tests/stub_libhttp.cc