hdr->putStr(Http::HdrType::CACHE_STATUS, cacheStatus.c_str());
const bool maySendChunkedReply = !request->multipartRangeRequest() &&
- reply->sline.protocol == AnyP::PROTO_HTTP && // response is HTTP
+ reply->sline.version.protocol == AnyP::PROTO_HTTP && // response is HTTP
(request->http_ver >= Http::ProtocolVersion(1,1));
/* Check whether we should send keep-alive */
http->al->reply = reply;
- if (reply->sline.protocol == AnyP::PROTO_HTTP) {
+ if (reply->sline.version.protocol == AnyP::PROTO_HTTP) {
/* RFC 2616 requires us to advertise our version (but only on real HTTP traffic) */
reply->sline.version = Http::ProtocolVersion();
}
// XXX: RFC 7230 indicates we MAY ignore the reason phrase,
// and use an empty string on unknown status.
// We do that now to avoid performance regression from using SBuf::c_str()
- newrep->sline.set(Http::ProtocolVersion(1,1), hp->messageStatus() /* , hp->reasonPhrase() */);
- newrep->sline.protocol = newrep->sline.version.protocol = hp->messageProtocol().protocol;
- newrep->sline.version.major = hp->messageProtocol().major;
- newrep->sline.version.minor = hp->messageProtocol().minor;
+ newrep->sline.set(hp->messageProtocol(), hp->messageStatus() /* , hp->reasonPhrase() */);
// parse headers
if (!newrep->parseHeader(*hp)) {
- // XXX: when Http::ProtocolVersion is a function, remove this hack. just set with messageProtocol()
- newrep->sline.set(Http::ProtocolVersion(), Http::scInvalidHeader);
- newrep->sline.version.protocol = hp->messageProtocol().protocol;
- newrep->sline.version.major = hp->messageProtocol().major;
- newrep->sline.version.minor = hp->messageProtocol().minor;
+ newrep->sline.set(hp->messageProtocol(), Http::scInvalidHeader);
debugs(11, 2, "error parsing response headers mime block");
}
newrep->removeStaleWarnings();
- if (newrep->sline.protocol == AnyP::PROTO_HTTP && Http::Is1xx(newrep->sline.status())) {
+ if (newrep->sline.version.protocol == AnyP::PROTO_HTTP && Http::Is1xx(newrep->sline.status())) {
handle1xx(newrep);
ctx_exit(ctx);
return;
}
flags.chunked = false;
- if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) {
+ if (newrep->sline.version.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) {
flags.chunked = true;
httpChunkDecoder = new Http1::TeChunkedParser;
}
void
Http::StatusLine::set(const AnyP::ProtocolVersion &newVersion, const Http::StatusCode newStatus, const char *newReason)
{
- protocol = AnyP::PROTO_HTTP;
version = newVersion;
status_ = newStatus;
/* Note: no xstrdup for 'reason', assumes constant 'reasons' */
static const char *IcyStatusLineFormat = "ICY %3d %s\r\n";
/* handle ICY protocol status line specially. Pass on the bad format. */
- if (protocol == AnyP::PROTO_ICY) {
+ if (version.protocol == AnyP::PROTO_ICY) {
debugs(57, 9, "packing sline " << this << " using " << p << ":");
debugs(57, 9, "FORMAT=" << IcyStatusLineFormat );
debugs(57, 9, "ICY " << packedStatus << " " << packedReason);
if (protoPrefix.cmp("ICY", 3) == 0) {
debugs(57, 3, "Invalid HTTP identifier. Detected ICY protocol instead.");
- protocol = AnyP::PROTO_ICY;
+ version = AnyP::ProtocolVersion(AnyP::PROTO_ICY, 1, 0);
start += protoPrefix.size();
} else if (protoPrefix.caseCmp(start, protoPrefix.size()) == 0) {
{
/**
- * Holds the values parsed from an HTTP reply status line.
+ * Holds the values parsed from an HTTP-like reply status line.
*
* For example: HTTP/1.1 200 OK
*/
public:
/* public, read only */
- /**
- * By rights protocol name should be a constant "HTTP", with no need for this field to exist.
- * However there are protocols which violate HTTP by sending their own custom formats
- * back with other protocol names (ICY streaming format being the current major problem).
- */
- // XXX: protocol is part of AnyP::ProtocolVersion. We should be able to use version.protocol instead now.
- AnyP::ProtocolType protocol;
-
AnyP::ProtocolVersion version; ///< breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
private:
/// status code. ie 100 ... 200 ... 404 ... 599
- Http::StatusCode status_;
+ Http::StatusCode status_ = scNone;
/// points to a _constant_ string (default or supplied), never free()d
- const char *reason_;
+ const char *reason_ = nullptr;
};
} // namespace Http