From: Amos Jeffries Date: Thu, 18 Dec 2014 12:12:33 +0000 (+1300) Subject: Bug 1961, Bug 429: Add asterisk to class URL X-Git-Tag: merge-candidate-3-v1~432 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e26020833b38cded2f6dec576a4a62483d19553;p=thirdparty%2Fsquid.git Bug 1961, Bug 429: Add asterisk to class URL This does not yet perform any of the outgoing request mapping from path-less URI required by current RFC 7231. Squid already allows these URI in OPTIONS and TRACE requests (only). It does make a start by cleaning up the current special case handling of "*" URI to be matched by the URI class/namespace method and SBuf comparisions instead of c-strings. --- diff --git a/src/URL.h b/src/URL.h index f58835f071..c17d59ab78 100644 --- a/src/URL.h +++ b/src/URL.h @@ -35,6 +35,9 @@ public: void userInfo(const SBuf &s) {userInfo_=s;} const SBuf &userInfo() const {return userInfo_;} + /// the static '*' pseudo-URL + static const SBuf &Asterisk(); + private: /** \par diff --git a/src/url.cc b/src/url.cc index 0a858eef26..3f62013b3b 100644 --- a/src/url.cc +++ b/src/url.cc @@ -37,6 +37,13 @@ static const char valid_hostname_chars[] = "[:]" ; +const SBuf & +URL::Asterisk() +{ + static SBuf star("*"); + return star; +} + void urlInitialize(void) { @@ -215,7 +222,7 @@ urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request) return NULL; } else if ((method == Http::METHOD_OPTIONS || method == Http::METHOD_TRACE) && - strcmp(url, "*") == 0) { + URL::Asterisk().cmp(url) == 0) { protocol = AnyP::PROTO_HTTP; port = urlDefaultPort(protocol); return urlParseFinish(method, protocol, url, host, SBuf(), port, request); @@ -794,7 +801,7 @@ urlCheckRequest(const HttpRequest * r) // we support OPTIONS and TRACE directed at us (with a 501 reply, for now) // we also support forwarding OPTIONS and TRACE, except for the *-URI ones if (r->method == Http::METHOD_OPTIONS || r->method == Http::METHOD_TRACE) - return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || r->urlpath != "*"); + return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || URL::Asterisk().cmp(r->urlpath.rawBuf(), r->urlpath.size()) != 0); if (r->method == Http::METHOD_PURGE) return 1;