Protocol agnostic class to store the request-line version details.
HTTP/1.0, HTTP/1.1, ICY/1.0, WebSockets/1.0 etc
For patch reduction leaves HttpVersion as a child class for HTTP/*.* tags
#ifndef SQUID_HTTPVERSION_H
#define SQUID_HTTPVERSION_H
-#if HAVE_OSTREAM
-#include <ostream>
-#endif
+#include "anyp/ProtocolVersion.h"
-class HttpVersion
+class HttpVersion : public AnyP::ProtocolVersion
{
-
public:
- HttpVersion() {
- major = 0;
- minor = 0;
- }
-
- HttpVersion(unsigned int aMajor, unsigned int aMinor) {
- major = aMajor;
- minor = aMinor;
- }
-
- unsigned int major;
- unsigned int minor;
-
- bool operator==(const HttpVersion& that) const {
- if (this->major != that.major)
- return false;
-
- if (this->minor != that.minor)
- return false;
-
- return true;
- }
+ HttpVersion() : AnyP::ProtocolVersion(AnyP::PROTO_HTTP,0,0) {}
- bool operator!=(const HttpVersion& that) const {
- return ((this->major != that.major) || (this->minor != that.minor));
- }
-
- bool operator <(const HttpVersion& that) const {
- return (this->major < that.major ||
- (this->major == that.major && this->minor < that.minor));
- }
-
- bool operator >(const HttpVersion& that) const {
- return (this->major > that.major ||
- (this->major == that.major && this->minor > that.minor));
- }
-
- bool operator <=(const HttpVersion& that) const {
- return !(*this > that);
- }
-
- bool operator >=(const HttpVersion& that) const {
- return !(*this < that);
- }
+ HttpVersion(unsigned int aMajor, unsigned int aMinor) : AnyP::ProtocolVersion(AnyP::PROTO_HTTP,aMajor,aMinor) {}
};
-inline std::ostream &
-operator << (std::ostream &os, const HttpVersion &v)
-{
- return (os << v.major << '.' << v.minor);
-}
-
#endif /* SQUID_HTTPVERSION_H */
libanyp_la_SOURCES = \
ProtocolType.cc \
- ProtocolType.h
+ ProtocolType.h \
+ ProtocolVersion.h
ProtocolType.cc: ProtocolType.h $(top_srcdir)/src/mk-string-arrays.awk
($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk <$(srcdir)/ProtocolType.h | sed -e 's%PROTO_%%' >$@) || ($(RM) -f $@ && exit 1)
--- /dev/null
+#ifndef SQUID_ANYP_PROTOCOLVERSION_H
+#define SQUID_ANYP_PROTOCOLVERSION_H
+
+#include "anyp/ProtocolType.h"
+
+#if HAVE_OSTREAM
+#include <ostream>
+#endif
+
+namespace AnyP
+{
+
+class ProtocolVersion
+{
+
+public:
+ // BUG: major() and minor() are macros.
+ // we can't use a fast constructor syntax without renaming them globally
+ ProtocolVersion() : protocol(PROTO_NONE) {
+ major = 0;
+ minor = 0;
+ }
+
+ ProtocolVersion(ProtocolType which, unsigned int aMajor, unsigned int aMinor) : protocol(which) {
+ major = aMajor;
+ minor = aMinor;
+ }
+
+ ProtocolType protocol;
+ unsigned int major;
+ unsigned int minor;
+
+ bool operator==(const ProtocolVersion& that) const {
+ if (this->protocol != that.protocol)
+ return false;
+
+ if (this->major != that.major)
+ return false;
+
+ if (this->minor != that.minor)
+ return false;
+
+ return true;
+ }
+
+ bool operator!=(const ProtocolVersion& that) const {
+ return (((this->protocol != that.protocol) || this->major != that.major) || (this->minor != that.minor));
+ }
+
+ bool operator <(const ProtocolVersion& that) const {
+ if (this->protocol != that.protocol)
+ return false; // throw?
+
+ return (this->major < that.major ||
+ (this->major == that.major && this->minor < that.minor));
+ }
+
+ bool operator >(const ProtocolVersion& that) const {
+ if (this->protocol != that.protocol)
+ return false; // throw?
+
+ return (this->major > that.major ||
+ (this->major == that.major && this->minor > that.minor));
+ }
+
+ bool operator <=(const ProtocolVersion& that) const {
+ if (this->protocol != that.protocol)
+ return false; // throw?
+
+ return !(*this > that);
+ }
+
+ bool operator >=(const ProtocolVersion& that) const {
+ if (this->protocol != that.protocol)
+ return false; // throw?
+
+ return !(*this < that);
+ }
+};
+
+} // namespace AnyP
+
+inline std::ostream &
+operator << (std::ostream &os, const AnyP::ProtocolVersion &v)
+{
+ return (os << AnyP::ProtocolType_str[v.protocol] << v.major << '.' << v.minor);
+}
+
+#endif /* SQUID_ANYP_PROTOCOLVERSION_H */
http->request = HTTPMSGLOCK(new_request);
} else {
debugs(85, DBG_CRITICAL, "ERROR: URL-rewrite produces invalid request: " <<
- old_request->method << " " << result << " HTTP/1.1");
+ old_request->method << " " << result << " " << old_request->http_ver);
delete new_request;
}
}
else
urlpath_or_slash = "/";
- str.Printf("%s " SQUIDSTRINGPH " HTTP/%d.%d\n",
+ str.Printf("%s " SQUIDSTRINGPH " %s/%d.%d\n",
RequestMethodStr(request->method),
SQUIDSTRINGPRINT(urlpath_or_slash),
+ AnyP::ProtocolType_str[request->http_ver.protocol],
request->http_ver.major, request->http_ver.minor);
packerToMemInit(&pck, &str);
request->header.packInto(&pck);
else
urlpath_or_slash = "/";
- mb.Printf("%s " SQUIDSTRINGPH " HTTP/%d.%d\n",
+ mb.Printf("%s " SQUIDSTRINGPH " %s/%d.%d\n",
RequestMethodStr(request->method),
SQUIDSTRINGPRINT(urlpath_or_slash),
+ AnyP::ProtocolType_str[request->http_ver.protocol],
request->http_ver.major, request->http_ver.minor);
packerToMemInit(&pck, &mb);
request->header.packInto(&pck);
url = entry->url();
else
url = request->urlpath.termedBuf();
- mb->Printf("%s %s HTTP/%d.%d\r\n",
+ mb->Printf("%s %s %s/%d.%d\r\n",
RequestMethodStr(request->method),
url && *url ? url : "/",
+ AnyP::ProtocolType_str[httpver.protocol],
httpver.major,httpver.minor);
/* build and pack headers */
{
if (!agent || *agent == '\0')
agent = "-";
- logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %"PRId64" \"%s\" \"%s\" %s%s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %"PRId64" \"%s\" \"%s\" %s%s:%s%s",
al->cache.caddr.NtoA(clientip,MAX_IPSTRLEN),
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
Time::FormatHttpd(squid_curtime),
al->_private.method_str,
al->url,
+ AnyP::ProtocolType_str[al->http.version.protocol],
al->http.version.major, al->http.version.minor,
al->http.code,
al->cache.replySize,
const char *user_auth = FormatName(al->cache.authuser);
const char *user_ident = FormatName(al->cache.rfc931);
- logfilePrintf(logfile, "%s %s %s [%s] \"%s %s HTTP/%d.%d\" %d %"PRId64" %s%s:%s%s",
+ logfilePrintf(logfile, "%s %s %s [%s] \"%s %s %s/%d.%d\" %d %"PRId64" %s%s:%s%s",
al->cache.caddr.NtoA(clientip,MAX_IPSTRLEN),
user_ident ? user_ident : dash_str,
user_auth ? user_auth : dash_str,
Time::FormatHttpd(squid_curtime),
al->_private.method_str,
al->url,
+ AnyP::ProtocolType_str[al->http.version.protocol],
al->http.version.major, al->http.version.minor,
al->http.code,
al->cache.replySize,
}
}
- debugs(26, 3, HERE << "'" << RequestMethodStr(request->method) << " " << url << " HTTP/" << request->http_ver << "'");
+ debugs(26, 3, HERE << "'" << RequestMethodStr(request->method) << " " << url << " " << request->http_ver << "'");
statCounter.server.all.requests++;
statCounter.server.other.requests++;