------------------------------------------------------------ revno: 13384 revision-id: squid3@treenet.co.nz-20140427075917-90sedongfbg7du97 parent: squid3@treenet.co.nz-20140425151414-mh4bkqkp5j6js6v1 fixes bug(s): http://bugs.squid-cache.org/show_bug.cgi?id=1961 committer: Amos Jeffries branch nick: trunk timestamp: Sun 2014-04-27 00:59:17 -0700 message: Bug 1961: pt1: URL handling redesign Replace the HttpMsg::protocol member (only used by HttpRequest) with a class URL member HttpRequest::url. To do this we adjust the class URL scheme_ member to be mutable via the makeScheme() setter, and add a clear() method to reset its internal state. These are necessary for HttpRequest init() and initHTTP() mechanisms, but fiddling with the scheme should be avoided as much as possible. Remove the hack of forcing internal requests to http:// for processing and cache lookup, then to internal:// for FwdState. Instead use the available flags.internal for requests identified to be served by this proxy. Drop the non-standard and now meaningless "internal://" scheme. Add debugging to display what internal indicators are detected and when the internal*() server and CacheManager are used by FwdState. Also document HttpMsg::http_ver which is a copy of the HTTP-Version field in the "on-wire" message syntax. It is unrelated to the socket transport protocol and the URL scheme protocol. ------------------------------------------------------------ # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: squid3@treenet.co.nz-20140427075917-90sedongfbg7du97 # target_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # testament_sha1: 921d292bf6d2306150725055a931a80e88c80584 # timestamp: 2014-04-27 08:53:48 +0000 # source_branch: http://bzr.squid-cache.org/bzr/squid3/trunk/ # base_revision_id: squid3@treenet.co.nz-20140425151414-\ # mh4bkqkp5j6js6v1 # # Begin patch === modified file 'src/FwdState.cc' --- src/FwdState.cc 2014-04-25 13:38:22 +0000 +++ src/FwdState.cc 2014-04-27 07:59:17 +0000 @@ -321,7 +321,7 @@ */ if ( Config.accessList.miss && !request->client_addr.isNoAddr() && - request->protocol != AnyP::PROTO_INTERNAL && request->protocol != AnyP::PROTO_CACHE_OBJECT) { + !request->flags.internal && request->url.getScheme() != AnyP::PROTO_CACHE_OBJECT) { /** * Check if this host is allowed to fetch MISSES from us (miss_access). * Intentionally replace the src_addr automatically selected by the checklist code @@ -361,13 +361,16 @@ return; } - switch (request->protocol) { - - case AnyP::PROTO_INTERNAL: + if (request->flags.internal) { + debugs(17, 2, "calling internalStart() due to request flag"); internalStart(clientConn, request, entry); return; + } + + switch (request->url.getScheme()) { case AnyP::PROTO_CACHE_OBJECT: + debugs(17, 2, "calling CacheManager due to request scheme " << request->url.getScheme()); CacheManager::GetInstance()->Start(clientConn, request, entry); return; @@ -692,7 +695,7 @@ #if USE_OPENSSL if (!request->flags.pinned) { if ((serverConnection()->getPeer() && serverConnection()->getPeer()->use_ssl) || - (!serverConnection()->getPeer() && request->protocol == AnyP::PROTO_HTTPS) || + (!serverConnection()->getPeer() && request->url.getScheme() == AnyP::PROTO_HTTPS) || request->flags.sslPeek) { HttpRequest::Pointer requestPointer = request; @@ -946,7 +949,7 @@ request->peer_login = NULL; request->peer_domain = NULL; - switch (request->protocol) { + switch (request->url.getScheme()) { #if USE_OPENSSL case AnyP::PROTO_HTTPS: @@ -968,8 +971,6 @@ case AnyP::PROTO_CACHE_OBJECT: - case AnyP::PROTO_INTERNAL: - case AnyP::PROTO_URN: fatal_dump("Should never get here"); break; === modified file 'src/HttpMsg.cc' --- src/HttpMsg.cc 2013-03-17 12:19:16 +0000 +++ src/HttpMsg.cc 2014-04-27 07:59:17 +0000 @@ -41,7 +41,7 @@ #include "SquidConfig.h" HttpMsg::HttpMsg(http_hdr_owner_type owner): header(owner), - cache_control(NULL), hdr_sz(0), content_length(0), protocol(AnyP::PROTO_NONE), + cache_control(NULL), hdr_sz(0), content_length(0), pstate(psReadyToParseStartLine) {} === modified file 'src/HttpMsg.h' --- src/HttpMsg.h 2013-10-25 00:13:46 +0000 +++ src/HttpMsg.h 2014-04-27 07:59:17 +0000 @@ -67,6 +67,8 @@ bool persistent() const; public: + /// HTTP-Version field in the first line of the message. + /// see draft-ietf-httpbis-p1-messaging-26 section 3.1 Http::ProtocolVersion http_ver; HttpHeader header; @@ -80,8 +82,6 @@ int64_t content_length; - AnyP::ProtocolType protocol; - HttpMsgParseState pstate; /* the current parsing state */ BodyPipe::Pointer body_pipe; // optional pipeline to receive message body === modified file 'src/HttpReply.cc' --- src/HttpReply.cc 2013-10-31 19:13:17 +0000 +++ src/HttpReply.cc 2014-04-27 07:59:17 +0000 @@ -604,7 +604,6 @@ rep->pstate = pstate; rep->body_pipe = body_pipe; - rep->protocol = protocol; // keep_alive is handled in hdrCacheInit() return rep; } === modified file 'src/HttpRequest.cc' --- src/HttpRequest.cc 2014-04-22 02:47:09 +0000 +++ src/HttpRequest.cc 2014-04-27 07:59:17 +0000 @@ -82,7 +82,7 @@ HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) { method = aMethod; - protocol = aProtocol; + url.setScheme(aProtocol); urlpath = aUrlpath; } @@ -90,7 +90,7 @@ HttpRequest::init() { method = Http::METHOD_NONE; - protocol = AnyP::PROTO_NONE; + url.clear(); urlpath = NULL; login[0] = '\0'; host[0] = '\0'; @@ -150,6 +150,7 @@ safe_free(vary_headers); + url.clear(); urlpath.clean(); header.clean(); @@ -197,7 +198,7 @@ HttpRequest * HttpRequest::clone() const { - HttpRequest *copy = new HttpRequest(method, protocol, urlpath.termedBuf()); + HttpRequest *copy = new HttpRequest(method, url.getScheme(), urlpath.termedBuf()); // TODO: move common cloning clone to Msg::copyTo() or copy ctor copy->header.append(&header); copy->hdrCacheInit(); @@ -594,7 +595,7 @@ if (!flags.hostVerified && (flags.intercepted || flags.interceptTproxy)) return false; - switch (protocol) { + switch (url.getScheme()) { case AnyP::PROTO_HTTP: case AnyP::PROTO_HTTPS: if (!method.respMaybeCacheable()) === modified file 'src/HttpRequest.h' --- src/HttpRequest.h 2014-03-15 02:50:12 +0000 +++ src/HttpRequest.h 2014-04-27 07:59:17 +0000 @@ -39,6 +39,7 @@ #include "HttpRequestMethod.h" #include "Notes.h" #include "RequestFlags.h" +#include "URL.h" #if USE_AUTH #include "auth/UserRequest.h" @@ -136,6 +137,9 @@ public: HttpRequestMethod method; + // TODO expand to include all URI parts + URL url; ///< the request URI (scheme only) + char login[MAX_LOGIN_SZ]; private: === modified file 'src/URL.h' --- src/URL.h 2014-02-07 13:45:20 +0000 +++ src/URL.h 2014-04-27 07:59:17 +0000 @@ -45,8 +45,16 @@ MEMPROXY_CLASS(URL); URL() : scheme_() {} URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {} + + void clear() { + scheme_=AnyP::PROTO_NONE; + } + AnyP::UriScheme const & getScheme() const {return scheme_;} + /// convert the URL scheme to that given + void setScheme(const AnyP::ProtocolType &p) {scheme_=p;} + private: /** \par @@ -68,7 +76,7 @@ * In order to make taking any of these routes easy, scheme is private * and immutable, only settable at construction time, */ - AnyP::UriScheme const scheme_; + AnyP::UriScheme scheme_; }; MEMPROXY_CLASS_INLINE(URL); === modified file 'src/acl/Protocol.cc' --- src/acl/Protocol.cc 2013-10-25 00:13:46 +0000 +++ src/acl/Protocol.cc 2014-04-27 07:59:17 +0000 @@ -42,9 +42,9 @@ template class ACLStrategised; int -ACLProtocolStrategy::match (ACLData * &data, ACLFilledChecklist *checklist, ACLFlags &) +ACLProtocolStrategy::match(ACLData * &data, ACLFilledChecklist *checklist, ACLFlags &) { - return data->match (checklist->request->protocol); + return data->match(checklist->request->url.getScheme()); } ACLProtocolStrategy * === modified file 'src/adaptation/ecap/Host.cc' --- src/adaptation/ecap/Host.cc 2014-02-08 13:36:42 +0000 +++ src/adaptation/ecap/Host.cc 2014-04-27 07:59:17 +0000 @@ -45,7 +45,6 @@ libecap::protocolWais.assignHostId(AnyP::PROTO_WAIS); libecap::protocolUrn.assignHostId(AnyP::PROTO_URN); libecap::protocolWhois.assignHostId(AnyP::PROTO_WHOIS); - protocolInternal.assignHostId(AnyP::PROTO_INTERNAL); protocolCacheObj.assignHostId(AnyP::PROTO_CACHE_OBJECT); protocolIcp.assignHostId(AnyP::PROTO_ICP); #if USE_HTCP === modified file 'src/adaptation/ecap/MessageRep.cc' --- src/adaptation/ecap/MessageRep.cc 2014-04-25 13:37:10 +0000 +++ src/adaptation/ecap/MessageRep.cc 2014-04-27 07:59:17 +0000 @@ -158,8 +158,6 @@ #endif case AnyP::PROTO_CACHE_OBJECT: return protocolCacheObj; - case AnyP::PROTO_INTERNAL: - return protocolInternal; case AnyP::PROTO_ICY: return protocolIcy; case AnyP::PROTO_COAP: === modified file 'src/anyp/ProtocolType.h' --- src/anyp/ProtocolType.h 2014-02-21 10:46:19 +0000 +++ src/anyp/ProtocolType.h 2014-04-27 07:59:17 +0000 @@ -27,7 +27,6 @@ #endif PROTO_URN, PROTO_WHOIS, - PROTO_INTERNAL, PROTO_ICY, PROTO_UNKNOWN, PROTO_MAX === modified file 'src/carp.cc' --- src/carp.cc 2014-04-25 10:47:59 +0000 +++ src/carp.cc 2014-04-27 07:59:17 +0000 @@ -191,9 +191,7 @@ //this code follows urlCanonical's pattern. // corner cases should use the canonical URL if (tp->options.carp_key.scheme) { - // temporary, until bug 1961 URL handling is fixed. - const AnyP::UriScheme sch(request->protocol); - key.append(sch.c_str()); + key.append(request->url.getScheme().c_str()); if (key.length()) //if the scheme is not empty key.append("://"); } === modified file 'src/cf.data.pre' --- src/cf.data.pre 2014-04-22 16:01:23 +0000 +++ src/cf.data.pre 2014-04-27 07:59:17 +0000 @@ -729,7 +729,7 @@ %SRCPORT Client source port %URI Requested URI %DST Requested host - %PROTO Requested protocol + %PROTO Requested URL scheme %PORT Requested port %PATH Requested URL path %METHOD Request method === modified file 'src/client_side.cc' --- src/client_side.cc 2014-04-22 12:51:21 +0000 +++ src/client_side.cc 2014-04-27 07:59:17 +0000 @@ -2720,20 +2720,23 @@ } if (internalCheck(request->urlpath.termedBuf())) { - if (internalHostnameIs(request->GetHost()) && - request->port == getMyPort()) { + if (internalHostnameIs(request->GetHost()) && request->port == getMyPort()) { + debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() << + ':' << request->port); http->flags.internal = true; } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.termedBuf())) { + debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() << + ':' << request->port << " (global_internal_static on)"); request->SetHost(internalHostname()); request->port = getMyPort(); http->flags.internal = true; - } + } else + debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() << + ':' << request->port << " (not this proxy)"); } - if (http->flags.internal) { - request->protocol = AnyP::PROTO_HTTP; + if (http->flags.internal) request->login[0] = '\0'; - } request->flags.internal = http->flags.internal; setLogUri (http, urlCanonicalClean(request.getRaw())); === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2014-04-22 02:47:09 +0000 +++ src/client_side_reply.cc 2014-04-27 07:59:17 +0000 @@ -583,7 +583,7 @@ */ http->logType = LOG_TCP_CLIENT_REFRESH_MISS; processMiss(); - } else if (r->protocol == AnyP::PROTO_HTTP) { + } else if (r->url.getScheme() == AnyP::PROTO_HTTP) { debugs(88, 3, "validate HIT object? YES."); /* * Object needs to be revalidated @@ -687,10 +687,6 @@ return; } - /** Check for internal requests. Update Protocol info if so. */ - if (http->flags.internal) - r->protocol = AnyP::PROTO_INTERNAL; - assert(r->clientConnectionManager == http->getConn()); /** Start forwarding to get the new object from network */ === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2014-04-22 02:47:09 +0000 +++ src/client_side_request.cc 2014-04-27 07:59:17 +0000 @@ -678,10 +678,10 @@ // Verify forward-proxy requested URL domain matches the Host: header debugs(85, 3, HERE << "FAIL on validate URL port " << http->request->port << " matches Host: port " << portStr); hostHeaderVerifyFailed("URL port", portStr); - } else if (!portStr && http->request->method != Http::METHOD_CONNECT && http->request->port != urlDefaultPort(http->request->protocol)) { + } else if (!portStr && http->request->method != Http::METHOD_CONNECT && http->request->port != urlDefaultPort(http->request->url.getScheme())) { // Verify forward-proxy requested URL domain matches the Host: header // Special case: we don't have a default-port to check for CONNECT. Assume URL is correct. - debugs(85, 3, HERE << "FAIL on validate URL port " << http->request->port << " matches Host: default port " << urlDefaultPort(http->request->protocol)); + debugs(85, 3, "FAIL on validate URL port " << http->request->port << " matches Host: default port " << urlDefaultPort(http->request->url.getScheme())); hostHeaderVerifyFailed("URL port", "default port"); } else { // Okay no problem. @@ -983,13 +983,13 @@ if (request->flags.loopDetected) return 0; - if (request->protocol == AnyP::PROTO_HTTP) + if (request->url.getScheme() == AnyP::PROTO_HTTP) return method.respMaybeCacheable(); - if (request->protocol == AnyP::PROTO_GOPHER) + if (request->url.getScheme() == AnyP::PROTO_GOPHER) return gopherCachable(request); - if (request->protocol == AnyP::PROTO_CACHE_OBJECT) + if (request->url.getScheme() == AnyP::PROTO_CACHE_OBJECT) return 0; return 1; === modified file 'src/errorpage.cc' --- src/errorpage.cc 2014-04-25 13:38:22 +0000 +++ src/errorpage.cc 2014-04-27 07:59:17 +0000 @@ -972,7 +972,7 @@ case 'P': if (request) { - p = AnyP::ProtocolType_str[request->protocol]; + p = request->url.getScheme().c_str(); } else if (!building_deny_info_url) { p = "[unknown protocol]"; } === modified file 'src/external_acl.cc' --- src/external_acl.cc 2014-04-22 02:47:09 +0000 +++ src/external_acl.cc 2014-04-27 07:59:17 +0000 @@ -1045,7 +1045,7 @@ break; case _external_acl_format::EXT_ACL_PROTO: - str = AnyP::ProtocolType_str[request->protocol]; + str = request->url.getScheme().c_str(); break; case _external_acl_format::EXT_ACL_PORT: === modified file 'src/ftp.cc' --- src/ftp.cc 2014-04-04 16:36:47 +0000 +++ src/ftp.cc 2014-04-27 07:59:17 +0000 @@ -3732,7 +3732,7 @@ { String newbuf = "%2f"; - if (request->protocol != AnyP::PROTO_FTP) + if (request->url.getScheme() != AnyP::PROTO_FTP) return NULL; if ( request->urlpath[0]=='/' ) { === modified file 'src/http.cc' --- src/http.cc 2014-04-22 02:47:09 +0000 +++ src/http.cc 2014-04-27 07:59:17 +0000 @@ -1807,7 +1807,7 @@ if (!hdr_out->has(HDR_HOST)) { if (request->peer_domain) { hdr_out->putStr(HDR_HOST, request->peer_domain); - } else if (request->port == urlDefaultPort(request->protocol)) { + } else if (request->port == urlDefaultPort(request->url.getScheme())) { /* use port# only if not default */ hdr_out->putStr(HDR_HOST, request->GetHost()); } else { @@ -1865,7 +1865,7 @@ /* append Front-End-Https */ if (flags.front_end_https) { - if (flags.front_end_https == 1 || request->protocol == AnyP::PROTO_HTTPS) + if (flags.front_end_https == 1 || request->url.getScheme() == AnyP::PROTO_HTTPS) hdr_out->putStr(HDR_FRONT_END_HTTPS, "On"); } @@ -1958,7 +1958,7 @@ else { /* use port# only if not default */ - if (request->port == urlDefaultPort(request->protocol)) { + if (request->port == urlDefaultPort(request->url.getScheme())) { hdr_out->putStr(HDR_HOST, request->GetHost()); } else { httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d", === modified file 'src/internal.cc' --- src/internal.cc 2013-10-25 00:13:46 +0000 +++ src/internal.cc 2014-04-27 07:59:17 +0000 @@ -73,6 +73,7 @@ entry->append(msgbuf, strlen(msgbuf)); entry->complete(); } else if (0 == strncmp(upath, "/squid-internal-mgr/", 20)) { + debugs(17, 2, "calling CacheManager due to URL-path /squid-internal-mgr/"); CacheManager::GetInstance()->Start(clientConn, request, entry); } else { debugObj(76, 1, "internalStart: unknown request:\n", === modified file 'src/peer_select.cc' --- src/peer_select.cc 2014-04-22 02:47:09 +0000 +++ src/peer_select.cc 2014-04-27 07:59:17 +0000 @@ -691,7 +691,7 @@ return; /* WAIS is not implemented natively */ - if (ps->request->protocol == AnyP::PROTO_WAIS) + if (ps->request->url.getScheme() == AnyP::PROTO_WAIS) return; peerAddFwdServer(&ps->servers, NULL, HIER_DIRECT); === modified file 'src/tests/testHttpRequest.cc' --- src/tests/testHttpRequest.cc 2013-10-25 00:13:46 +0000 +++ src/tests/testHttpRequest.cc 2014-04-27 07:59:17 +0000 @@ -43,7 +43,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); @@ -55,7 +55,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_PUT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://foo/bar"), String(url)); xfree(url); @@ -73,7 +73,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_CONNECT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String(""), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("foo:45"), String(url)); xfree(url); } @@ -93,7 +93,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); } @@ -116,7 +116,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]/foo"), String(url)); xfree(url); @@ -128,7 +128,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]:90/foo"), String(url)); xfree(url); @@ -140,7 +140,7 @@ CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast(aRequest->url.getScheme())); CPPUNIT_ASSERT_EQUAL(String("http://2000:800::45/foo"), String(url)); xfree(url); } === modified file 'src/url.cc' --- src/url.cc 2014-04-23 15:36:13 +0000 +++ src/url.cc 2014-04-27 07:59:17 +0000 @@ -146,9 +146,6 @@ if (strncasecmp(b, "whois", len) == 0) return AnyP::PROTO_WHOIS; - if (strncasecmp(b, "internal", len) == 0) - return AnyP::PROTO_INTERNAL; - return AnyP::PROTO_NONE; } @@ -179,8 +176,6 @@ return 210; case AnyP::PROTO_CACHE_OBJECT: - - case AnyP::PROTO_INTERNAL: return CACHE_HTTP_PORT; case AnyP::PROTO_WHOIS: @@ -503,7 +498,7 @@ if (request->canonical) return request->canonical; - if (request->protocol == AnyP::PROTO_URN) { + if (request->url.getScheme() == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { @@ -517,12 +512,11 @@ { portbuf[0] = '\0'; - if (request->port != urlDefaultPort(request->protocol)) + if (request->port != urlDefaultPort(request->url.getScheme())) snprintf(portbuf, 32, ":%d", request->port); - const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(urlbuf, MAX_URL, "%s://%s%s%s%s" SQUIDSTRINGPH, - sch.c_str(), + request->url.getScheme().c_str(), request->login, *request->login ? "@" : null_string, request->GetHost(), @@ -547,7 +541,7 @@ LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1); char *t; - if (request->protocol == AnyP::PROTO_URN) { + if (request->url.getScheme() == AnyP::PROTO_URN) { snprintf(buf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { @@ -561,7 +555,7 @@ { portbuf[0] = '\0'; - if (request->port != urlDefaultPort(request->protocol)) + if (request->port != urlDefaultPort(request->url.getScheme())) snprintf(portbuf, 32, ":%d", request->port); loginbuf[0] = '\0'; @@ -575,9 +569,8 @@ strcat(loginbuf, "@"); } - const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed. snprintf(buf, MAX_URL, "%s://%s%s%s" SQUIDSTRINGPH, - sch.c_str(), + request->url.getScheme().c_str(), loginbuf, request->GetHost(), portbuf, @@ -667,7 +660,7 @@ char *urlbuf = (char *)xmalloc(MAX_URL * sizeof(char)); - if (req->protocol == AnyP::PROTO_URN) { + if (req->url.getScheme() == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(req->urlpath)); return (urlbuf); @@ -675,10 +668,9 @@ size_t urllen; - const AnyP::UriScheme sch = req->protocol; // temporary, until bug 1961 URL handling is fixed. - if (req->port != urlDefaultPort(req->protocol)) { + if (req->port != urlDefaultPort(req->url.getScheme())) { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s:%d", - sch.c_str(), + req->url.getScheme().c_str(), req->login, *req->login ? "@" : null_string, req->GetHost(), @@ -686,7 +678,7 @@ ); } else { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s", - sch.c_str(), + req->url.getScheme().c_str(), req->login, *req->login ? "@" : null_string, req->GetHost() @@ -844,7 +836,7 @@ return 1; /* does method match the protocol? */ - switch (r->protocol) { + switch (r->url.getScheme()) { case AnyP::PROTO_URN: