HttpRequestMethod method;
int code;
const char *content_type;
- Http::ProtocolVersion version;
+ AnyP::ProtocolVersion version;
bool timedout; ///< terminated due to a lifetime or I/O timeout
bool aborted; ///< other abnormal termination (e.g., I/O error)
bool
HttpMsg::persistent() const
{
- if (http_ver > Http::ProtocolVersion(1, 0)) {
+ if (http_ver > Http::ProtocolVersion(1,0)) {
/*
* for modern versions of HTTP: persistent unless there is
* a "Connection: close" header.
public:
/// HTTP-Version field in the first line of the message.
/// see RFC 7230 section 3.1
- Http::ProtocolVersion http_ver;
+ AnyP::ProtocolVersion http_ver;
HttpHeader header;
/* rv->cache_control */
/* rv->content_range */
/* rv->keep_alive */
- rv->sline.set(Http::ProtocolVersion(1,1), Http::scNotModified, NULL);
+ rv->sline.set(Http::ProtocolVersion(), Http::scNotModified, NULL);
for (t = 0; ImsEntries[t] != HDR_OTHER; ++t)
if ((e = header.findEntry(ImsEntries[t])))
const char *ctype, int64_t clen, time_t lmt, time_t expiresTime)
{
HttpHeader *hdr;
- sline.set(Http::ProtocolVersion(1,1), status, reason);
+ sline.set(Http::ProtocolVersion(), status, reason);
hdr = &header;
hdr->putStr(HDR_SERVER, visible_appname_string);
hdr->putStr(HDR_MIME_VERSION, "1.0");
HttpReply::redirect(Http::StatusCode status, const char *loc)
{
HttpHeader *hdr;
- sline.set(Http::ProtocolVersion(1,1), status, NULL);
+ sline.set(Http::ProtocolVersion(), status, NULL);
hdr = &header;
hdr->putStr(HDR_SERVER, APP_FULLNAME);
hdr->putTime(HDR_DATE, squid_curtime);
{
int result(HttpMsg::httpMsgParseError());
/* indicate an error in the status line */
- sline.set(Http::ProtocolVersion(1,1), Http::scInvalidHeader);
+ sline.set(Http::ProtocolVersion(), Http::scInvalidHeader);
return result;
}
const bool maySendChunkedReply = !request->multipartRangeRequest() &&
reply->sline.protocol == AnyP::PROTO_HTTP && // response is HTTP
- (request->http_ver >= Http::ProtocolVersion(1, 1));
+ (request->http_ver >= Http::ProtocolVersion(1,1));
/* Check whether we should send keep-alive */
if (!Config.onoff.error_pconns && reply->sline.status() >= 400 && !request->flags.mustKeepalive) {
HTTPMSGLOCK(reply);
if (reply->sline.protocol == AnyP::PROTO_HTTP) {
- /* RFC 2616 requires us to advertise our 1.1 version (but only on real HTTP traffic) */
- reply->sline.version = Http::ProtocolVersion(1,1);
+ /* RFC 2616 requires us to advertise our version (but only on real HTTP traffic) */
+ reply->sline.version = Http::ProtocolVersion();
}
/* do header conversions */
request->my_addr.port(0);
- /* Our version is HTTP/1.1 */
- request->http_ver = Http::ProtocolVersion(1,1);
+ request->http_ver = Http::ProtocolVersion();
http->request = request;
HTTPMSGLOCK(http->request);
{
HttpReply *const reply = new HttpReply;
- Http::ProtocolVersion httpVersion = Http::ProtocolVersion(
+ AnyP::ProtocolVersion httpVersion = Http::ProtocolVersion(
Ftp::ProtocolVersion().major, Ftp::ProtocolVersion().minor);
reply->sline.set(httpVersion, httpStatus);
flags.headers_parsed = true;
// XXX: when sanityCheck is gone and Http::StatusLine is used to parse,
// the sline should be already set the appropriate values during that parser stage
- newrep->sline.set(Http::ProtocolVersion(1,1), error);
+ newrep->sline.set(Http::ProtocolVersion(), error);
HttpReply *vrep = setVirginReply(newrep);
entry->replaceHttpReply(vrep);
ctx_exit(ctx);
// check for header parsing errors
if (HttpReply *vrep = virginReply()) {
const Http::StatusCode s = vrep->sline.status();
- const Http::ProtocolVersion &v = vrep->sline.version;
+ const AnyP::ProtocolVersion &v = vrep->sline.version;
if (s == Http::scInvalidHeader && v != Http::ProtocolVersion(0,9)) {
debugs(11, DBG_IMPORTANT, "WARNING: HTTP: Invalid Response: Bad header encountered from " << entry->url() << " AKA " << request->GetHost() << request->urlpath.termedBuf() );
error = ERR_INVALID_RESP;
HttpStateData::buildRequestPrefix(MemBuf * mb)
{
const int offset = mb->size;
- /* Uses a local httpver variable to print the HTTP/1.1 label
+ /* Uses a local httpver variable to print the HTTP label
* since the HttpRequest may have an older version label.
* XXX: This could create protocol bugs as the headers sent and
* flow control should all be based on the HttpRequest version
* not the one we are sending. Needs checking.
*/
- Http::ProtocolVersion httpver(1,1);
+ const AnyP::ProtocolVersion httpver = Http::ProtocolVersion();
const char * url;
if (_peer && !_peer->options.originserver)
url = urlCanonical(request);
namespace Http
{
+/// HTTP version label information
+inline AnyP::ProtocolVersion
+ProtocolVersion(unsigned int aMajor, unsigned int aMinor)
+{
+ return AnyP::ProtocolVersion(AnyP::PROTO_HTTP,aMajor,aMinor);
+}
+
/**
- * Stores HTTP version label information.
+ * HTTP version label information.
*
- * Squid being conditionally compliant with RFC 2616
+ * Squid being conditionally compliant with RFC 7230
* on both client and server connections the default
* value is HTTP/1.1.
*/
-class ProtocolVersion : public AnyP::ProtocolVersion
+inline AnyP::ProtocolVersion
+ProtocolVersion()
{
-public:
- ProtocolVersion() : AnyP::ProtocolVersion(AnyP::PROTO_HTTP,1,1) {}
-
- ProtocolVersion(unsigned int aMajor, unsigned int aMinor) : AnyP::ProtocolVersion(AnyP::PROTO_HTTP,aMajor,aMinor) {}
-};
+ return AnyP::ProtocolVersion(AnyP::PROTO_HTTP,1,1);
+}
}; // namespace Http
/* set values */
void
-Http::StatusLine::set(const Http::ProtocolVersion &newVersion, const Http::StatusCode newStatus, const char *newReason)
+Http::StatusLine::set(const AnyP::ProtocolVersion &newVersion, const Http::StatusCode newStatus, const char *newReason)
{
protocol = AnyP::PROTO_HTTP;
version = newVersion;
/// set this status-line to the given values
/// when reason is NULL the default message text for this StatusCode will be used
- void set(const Http::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL);
+ void set(const AnyP::ProtocolVersion &newVersion, Http::StatusCode newStatus, const char *newReason = NULL);
/// retrieve the status code for this status line
Http::StatusCode status() const { return status_; }
* 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 Http::ProtocolVersion. We should be able to use version.protocol instead now.
+ // XXX: protocol is part of AnyP::ProtocolVersion. We should be able to use version.protocol instead now.
AnyP::ProtocolType protocol;
- Http::ProtocolVersion version; ///< breakdown of protocol version label: (HTTP/ICY) and (0.9/1.0/1.1)
+ 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
HTTPMSGLOCK(ex->r);
assert(NULL != ex->r);
- ex->r->http_ver = Http::ProtocolVersion(1,1);
+ ex->r->http_ver = Http::ProtocolVersion();
ex->connstate = STATE_HEADER;
ex->e = storeCreateEntry(uri, uri, RequestFlags(), Http::METHOD_GET);
ex->buf_sz = NETDB_REQBUF_SZ;
request->forcedBodyContinuation = true;
//sendControlMsg
HttpReply::Pointer rep = new HttpReply;
- rep->sline.set(Http::ProtocolVersion(1,1), Http::scContinue);
+ rep->sline.set(Http::ProtocolVersion(), Http::scContinue);
typedef UnaryMemFunT<Http::Server, ClientSocketContext::Pointer> CbDialer;
const AsyncCall::Pointer cb = asyncCall(11, 3, "Http::Server::proceedAfterBodyContinuation", CbDialer(this, &Http::Server::proceedAfterBodyContinuation, ClientSocketContext::Pointer(context)));