From 3dcd14eedeb5f933b8f45dfcd7a918fdbb12562e Mon Sep 17 00:00:00 2001 From: "valeski%netscape.com" Date: Tue, 13 Mar 2001 02:01:07 +0000 Subject: [PATCH] sr=rpotts, r=gagan. 70743. switching over to new extensible URI::SchemeIs() api. and changing existing implementations over to new api. also modified nsHTTP and nsHTTPS handlers a bit to make things cleaner. git-svn-id: svn://10.0.0.236/trunk@89421 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/modules/libjar/nsJARURI.cpp | 16 ++++---- mozilla/modules/libjar/nsJARURI.h | 1 - mozilla/netwerk/base/public/nsIURI.idl | 26 ++---------- mozilla/netwerk/base/src/nsSimpleURI.cpp | 19 +++++---- mozilla/netwerk/base/src/nsSimpleURI.h | 1 - mozilla/netwerk/base/src/nsStdURL.cpp | 21 +++++----- mozilla/netwerk/base/src/nsStdURL.h | 1 - mozilla/netwerk/base/src/nsURLHelper.cpp | 39 ------------------ mozilla/netwerk/base/src/nsURLHelper.h | 3 -- mozilla/netwerk/build/nsNetModule.cpp | 4 +- .../protocol/http/src/nsHTTPChannel.cpp | 2 +- .../protocol/http/src/nsHTTPHandler.cpp | 11 +++-- .../netwerk/protocol/http/src/nsHTTPHandler.h | 2 +- .../protocol/http/src/nsHTTPSHandler.cpp | 41 +++++++------------ .../protocol/http/src/nsHTTPSHandler.h | 13 +----- mozilla/netwerk/protocol/jar/src/nsJARURI.cpp | 16 ++++---- mozilla/netwerk/protocol/jar/src/nsJARURI.h | 1 - .../converters/nsUnknownDecoder.cpp | 2 +- 18 files changed, 71 insertions(+), 148 deletions(-) diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index 87e46b2b823..1f1be0a13a2 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -30,8 +30,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// nsJARURI::nsJARURI() - : mJAREntry(nsnull), - mSchemeType(nsIURI::JAR) + : mJAREntry(nsnull) { NS_INIT_REFCNT(); } @@ -116,7 +115,6 @@ nsJARURI::SetSpec(const char * aSpec) if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0) return NS_ERROR_MALFORMED_URI; - mSchemeType = nsIURI::JAR; // Search backward from the end for the "!/" delimiter. Remember, jar URLs // can nest, e.g.: // jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html @@ -277,12 +275,16 @@ nsJARURI::Equals(nsIURI *other, PRBool *result) } NS_IMETHODIMP -nsJARURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +nsJARURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals) { NS_ENSURE_ARG_POINTER(o_Equals); - if (i_Scheme == nsIURI::UNKNOWN) - return NS_ERROR_INVALID_ARG; - *o_Equals = (mSchemeType == i_Scheme); + if (!i_Scheme) return NS_ERROR_INVALID_ARG; + + if (*i_Scheme == 'j' || *i_Scheme == 'J') { + *o_Equals = PL_strcasecmp("jar", i_Scheme) ? PR_FALSE : PR_TRUE; + } else { + *o_Equals = PR_FALSE; + } return NS_OK; } diff --git a/mozilla/modules/libjar/nsJARURI.h b/mozilla/modules/libjar/nsJARURI.h index d45d56e51e8..fbbc9e96286 100644 --- a/mozilla/modules/libjar/nsJARURI.h +++ b/mozilla/modules/libjar/nsJARURI.h @@ -50,7 +50,6 @@ public: protected: nsCOMPtr mJARFile; char *mJAREntry; - PRUint32 mSchemeType; }; #endif // nsJARURI_h__ diff --git a/mozilla/netwerk/base/public/nsIURI.idl b/mozilla/netwerk/base/public/nsIURI.idl index ee90c6f44a5..0c48dea6871 100644 --- a/mozilla/netwerk/base/public/nsIURI.idl +++ b/mozilla/netwerk/base/public/nsIURI.idl @@ -65,25 +65,6 @@ [scriptable, uuid(07a22cc0-0ce5-11d3-9331-00104ba0fd40)] interface nsIURI : nsISupports { - /** - * List of standard/known URL scheme types for quicker lookups and - * comparisons. The UNKNOWN type applies for all other cases. - */ - const PRUint32 UNKNOWN = 0; - const PRUint32 ABOUT = 1; - const PRUint32 CHROME = 2; - const PRUint32 FILE = 3; - const PRUint32 FTP = 4; - const PRUint32 HTTP = 5; - const PRUint32 HTTPS = 6; - const PRUint32 IMAP = 7; - const PRUint32 JAR = 8; - const PRUint32 JAVASCRIPT = 9; - const PRUint32 MAILBOX = 10; - const PRUint32 MAILTO = 11; - const PRUint32 NEWS = 12; - const PRUint32 RESOURCE = 13; - const PRUint32 LDAP = 14; /** * Returns a string representation of the URI. Setting the spec @@ -156,11 +137,10 @@ interface nsIURI : nsISupports /** * An optimization to do scheme checks without requiring the users of nsIURI * to GetScheme thereby saving extra allocating and freeing. Returns true if - * the schemes match (case ignored) to one of the standard known types - * mentioned above. Note that for unknown cases this will always return - * false. + * the schemes match (case ignored). Note that for unknown cases this will + * always return false. */ - boolean schemeIs(in PRUint32 scheme); + boolean schemeIs(in string scheme); /** * Clones the current URI. The newly created URI will be in a closed diff --git a/mozilla/netwerk/base/src/nsSimpleURI.cpp b/mozilla/netwerk/base/src/nsSimpleURI.cpp index 6d508f6d484..29283aecf43 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.cpp +++ b/mozilla/netwerk/base/src/nsSimpleURI.cpp @@ -41,8 +41,7 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); nsSimpleURI::nsSimpleURI(nsISupports* outer) : mScheme(nsnull), - mPath(nsnull), - mSchemeType(nsIURI::UNKNOWN) + mPath(nsnull) { NS_INIT_AGGREGATED(outer); } @@ -113,7 +112,6 @@ nsSimpleURI::SetSpec(const char* aSpec) mScheme = scheme.ToNewCString(); if (mScheme == nsnull) return NS_ERROR_OUT_OF_MEMORY; - mSchemeType = SchemeTypeFor(mScheme); if (mPath) nsCRT::free(mPath); mPath = path.ToNewCString(); @@ -134,6 +132,7 @@ nsSimpleURI::SetScheme(const char* scheme) { if (mScheme) nsCRT::free(mScheme); mScheme = nsCRT::strdup(scheme); + ToLowerCase(mScheme); return NS_OK; } @@ -250,12 +249,18 @@ nsSimpleURI::Equals(nsIURI* other, PRBool *result) } NS_IMETHODIMP -nsSimpleURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +nsSimpleURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals) { NS_ENSURE_ARG_POINTER(o_Equals); - if (i_Scheme == nsIURI::UNKNOWN) - return NS_ERROR_INVALID_ARG; - *o_Equals = (mSchemeType == i_Scheme); + if (!i_Scheme) return NS_ERROR_NULL_POINTER; + + // mScheme is guaranteed to be lower case. + if (*i_Scheme == *mScheme || *i_Scheme == (*mScheme - ('a' - 'A')) ) { + *o_Equals = PL_strcasecmp(mScheme, i_Scheme) ? PR_FALSE : PR_TRUE; + } else { + *o_Equals = PR_FALSE; + } + return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsSimpleURI.h b/mozilla/netwerk/base/src/nsSimpleURI.h index 1f22d33abda..b68a2470b19 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.h +++ b/mozilla/netwerk/base/src/nsSimpleURI.h @@ -51,7 +51,6 @@ public: protected: char* mScheme; char* mPath; - PRUint32 mSchemeType; }; #endif // nsSimpleURI_h__ diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index 17d413ca619..233afc1f48b 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -118,8 +118,7 @@ nsStdURL::nsStdURL(nsISupports* outer) mParam(nsnull), mQuery(nsnull), mRef(nsnull), - mDefaultPort(-1), - mSchemeType(nsIURI::UNKNOWN) + mDefaultPort(-1) { NS_INIT_AGGREGATED(outer); InitGlobalObjects(); @@ -176,7 +175,6 @@ nsStdURL::nsStdURL(const nsStdURL& otherURL) mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; mURLParser = otherURL.mURLParser; - mSchemeType = otherURL.mSchemeType; NS_INIT_AGGREGATED(nsnull); // Todo! How? } @@ -195,7 +193,6 @@ nsStdURL::operator=(const nsStdURL& otherURL) mQuery = otherURL.mQuery ? nsCRT::strdup(otherURL.mQuery) : nsnull; mRef= otherURL.mRef ? nsCRT::strdup(otherURL.mRef) : nsnull; mURLParser = otherURL.mURLParser; - mSchemeType = otherURL.mSchemeType; NS_INIT_AGGREGATED(nsnull); // Todo! How? return *this; @@ -306,12 +303,18 @@ nsStdURL::Equals(nsIURI *i_OtherURI, PRBool *o_Equals) } NS_IMETHODIMP -nsStdURL::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +nsStdURL::SchemeIs(const char *i_Scheme, PRBool *o_Equals) { NS_ENSURE_ARG_POINTER(o_Equals); - if (i_Scheme == nsIURI::UNKNOWN) - return NS_ERROR_INVALID_ARG; - *o_Equals = (mSchemeType == i_Scheme); + if (!i_Scheme) return NS_ERROR_NULL_POINTER; + + // mScheme is guaranteed to be lower case. + if (*i_Scheme == *mScheme || *i_Scheme == (*mScheme - ('a' - 'A')) ) { + *o_Equals = PL_strcasecmp(mScheme, i_Scheme) ? PR_FALSE : PR_TRUE; + } else { + *o_Equals = PR_FALSE; + } + return NS_OK; } @@ -344,8 +347,6 @@ nsStdURL::Parse(const char* i_Spec) nsresult rv = mURLParser->ParseAtScheme(i_Spec, &mScheme, &mUsername, &mPassword, &mHost, &mPort, &ePath); - mSchemeType = SchemeTypeFor(mScheme); - if (NS_SUCCEEDED(rv)) { // Now parse the path rv = mURLParser->ParseAtDirectory(ePath, &mDirectory, &mFileBaseName, diff --git a/mozilla/netwerk/base/src/nsStdURL.h b/mozilla/netwerk/base/src/nsStdURL.h index 95acb4d5e63..ae6775f57ce 100644 --- a/mozilla/netwerk/base/src/nsStdURL.h +++ b/mozilla/netwerk/base/src/nsStdURL.h @@ -100,7 +100,6 @@ protected: nsCOMPtr mURLParser; PRInt32 mDefaultPort; // port for protocol (used for canonicalizing, // and printing) - PRUint32 mSchemeType; // Global objects. Dont use comptr as its destructor will cause diff --git a/mozilla/netwerk/base/src/nsURLHelper.cpp b/mozilla/netwerk/base/src/nsURLHelper.cpp index bb07fae0539..01dcba94336 100644 --- a/mozilla/netwerk/base/src/nsURLHelper.cpp +++ b/mozilla/netwerk/base/src/nsURLHelper.cpp @@ -395,42 +395,3 @@ NS_NET nsresult ExtractURLScheme(const char* inURI, PRUint32 *startPos, } return NS_ERROR_MALFORMED_URI; } - -/* Convert the URI string to a known case (or nsIURI::UNKNOWN) */ -NS_NET PRUint32 SchemeTypeFor(const char* i_scheme) -{ - // This order is a speculation on what gets used more (or needs more - // help in optimizing) - if (!i_scheme) - return nsIURI::UNKNOWN; - if (0 == PL_strcasecmp("chrome", i_scheme)) - return nsIURI::CHROME; - else if (0 == PL_strcasecmp("resource", i_scheme)) - return nsIURI::RESOURCE; - else if (0 == PL_strcasecmp("jar", i_scheme)) - return nsIURI::JAR; - else if (0 == PL_strcasecmp("file", i_scheme)) - return nsIURI::FILE; - else if (0 == PL_strcasecmp("http", i_scheme)) - return nsIURI::HTTP; - else if (0 == PL_strcasecmp("ftp", i_scheme)) - return nsIURI::FTP; - else if (0 == PL_strcasecmp("https", i_scheme)) - return nsIURI::HTTPS; - else if (0 == PL_strcasecmp("mailbox", i_scheme)) - return nsIURI::MAILBOX; - else if (0 == PL_strcasecmp("imap", i_scheme)) - return nsIURI::IMAP; - else if (0 == PL_strcasecmp("javascript", i_scheme)) - return nsIURI::JAVASCRIPT; - else if (0 == PL_strcasecmp("about", i_scheme)) - return nsIURI::ABOUT; - else if (0 == PL_strcasecmp("mailto", i_scheme)) - return nsIURI::MAILTO; - else if (0 == PL_strcasecmp("news", i_scheme)) - return nsIURI::NEWS; - else if (0 == PL_strcasecmp("ldap", i_scheme)) - return nsIURI::LDAP; - else - return nsIURI::UNKNOWN; -} diff --git a/mozilla/netwerk/base/src/nsURLHelper.h b/mozilla/netwerk/base/src/nsURLHelper.h index 9bf46d1a89c..9afaf943365 100644 --- a/mozilla/netwerk/base/src/nsURLHelper.h +++ b/mozilla/netwerk/base/src/nsURLHelper.h @@ -81,9 +81,6 @@ NS_NET void ToLowerCase(char* str); NS_NET nsresult ExtractURLScheme(const char* inURI, PRUint32 *startPos, PRUint32 *endPos, char* *scheme); -/* Convert the URI string to a known case (or nsIURI::UNKNOWN) */ -NS_NET PRUint32 SchemeTypeFor(const char* iScheme); - #ifdef __cplusplus } #endif diff --git a/mozilla/netwerk/build/nsNetModule.cpp b/mozilla/netwerk/build/nsNetModule.cpp index 010711465a0..a6f9d54fe93 100644 --- a/mozilla/netwerk/build/nsNetModule.cpp +++ b/mozilla/netwerk/build/nsNetModule.cpp @@ -111,7 +111,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsStorageTransport) #include "nsBasicAuth.h" NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPHandler, Init); -//NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTTPSHandler); +NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHTTPSHandler, Init); #define NS_HTTPS_HANDLER_FACTORY_CID { 0xd2771480, 0xcac4, 0x11d3, { 0x8c, 0xaf, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } } @@ -764,7 +764,7 @@ static nsModuleComponentInfo gNetModuleInfo[] = { { "HTTPS Handler", NS_HTTPS_HANDLER_FACTORY_CID, NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "https", - nsHTTPSHandler::Create }, + nsHTTPSHandlerConstructor }, { "Basic Auth Encoder", NS_BASICAUTH_CID, NS_BASICAUTH_CONTRACTID, diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp index 3af7e77060c..b3a94ef5fcd 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPChannel.cpp @@ -127,7 +127,7 @@ nsHTTPChannel::nsHTTPChannel(nsIURI *aURL, nsHTTPHandler *aHandler) #endif PRBool isHTTPS = PR_FALSE; - if (NS_SUCCEEDED(mURI->SchemeIs(nsIURI::HTTPS, &isHTTPS)) && isHTTPS) + if (NS_SUCCEEDED(mURI->SchemeIs("https", &isHTTPS)) && isHTTPS) mLoadAttributes |= nsIChannel::INHIBIT_PERSISTENT_CACHING; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp index 773a25ccfea..5775a6522a7 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp @@ -117,8 +117,7 @@ nsHTTPHandler::GetDefaultPort(PRInt32 *result) NS_IMETHODIMP nsHTTPHandler::GetScheme(char * *o_Scheme) { - static const char* scheme = "http"; - *o_Scheme = nsCRT::strdup(scheme); + *o_Scheme = nsCRT::strdup(mScheme); return NS_OK; } @@ -612,10 +611,10 @@ nsHTTPHandler::nsHTTPHandler(): mPipelineFirstRequest(PR_FALSE), mPipelineMaxRequests(DEFAULT_PIPELINE_MAX_REQUESTS), mReferrerLevel(0), - mScheme(nsIURI::HTTP), mRequestTimeout(DEFAULT_HTTP_REQUEST_TIMEOUT), mConnectTimeout(DEFAULT_HTTP_CONNECT_TIMEOUT), - mProxySSLConnectAllowed(PR_FALSE) + mProxySSLConnectAllowed(PR_FALSE), + mScheme(nsnull) { NS_INIT_REFCNT(); SetAcceptEncodings(DEFAULT_ACCEPT_ENCODINGS); @@ -838,6 +837,9 @@ nsHTTPHandler::Init() NS_WITH_SERVICE(nsIObserverService, observerService, NS_OBSERVERSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv)) observerService->AddObserver(this, NS_LITERAL_STRING("profile-before-change").get()); + + mScheme = nsCRT::strdup("http"); + if (!mScheme) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -872,6 +874,7 @@ nsHTTPHandler::~nsHTTPHandler() CRTFREEIF (mAcceptLanguages); CRTFREEIF (mAcceptEncodings); + CRTFREEIF (mScheme); } nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri, diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h index bdcf7c730f9..96324981531 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.h @@ -202,7 +202,7 @@ protected: nsCString mProductComment; nsCString mAppUserAgentOverride; - PRInt32 mScheme; + char * mScheme; // used by nsHTTPHandler and nsHTTPSHandler private: diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp index 02a891bc25e..a1c8500e13f 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.cpp @@ -32,40 +32,27 @@ static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID); nsHTTPSHandler::nsHTTPSHandler() : nsHTTPHandler() { - nsresult rv; - nsISupports *psm = nsnull; - // - // Initialize the PSM component. - // This is to ensure that PSM is initialized on the main UI thread. - // - rv = nsServiceManager::GetService( PSM_COMPONENT_CONTRACTID, - NS_GET_IID(nsISecurityManagerComponent), - (nsISupports**)&psm); - - NS_IF_RELEASE(psm); - mScheme = nsIURI::HTTPS; } nsHTTPSHandler::~nsHTTPSHandler() { } -NS_METHOD -nsHTTPSHandler::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) -{ - nsresult rv; - if (aOuter) return NS_ERROR_NO_AGGREGATION; +nsresult +nsHTTPSHandler::Init() { + nsresult rv = NS_OK; - nsHTTPSHandler* handler = new nsHTTPSHandler(); - if (!handler) return NS_ERROR_OUT_OF_MEMORY; - NS_ADDREF(handler); - rv = handler->Init(); - if (NS_FAILED(rv)) { - delete handler; - return rv; - } - rv = handler->QueryInterface(aIID, aResult); - NS_RELEASE(handler); + // init nsHTTPHandler *first* + rv = nsHTTPHandler::Init(); + if (NS_FAILED(rv)) return rv; + + // done to "init" psm. + nsCOMPtr psm(do_GetService(PSM_COMPONENT_CONTRACTID, &rv)); + if (NS_FAILED(rv)) return rv; + + if (mScheme) nsCRT::free(mScheme); + mScheme = nsCRT::strdup("https"); + if (!mScheme) return NS_ERROR_OUT_OF_MEMORY; return rv; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h index 925ae459827..019a01e600c 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHTTPSHandler.h @@ -40,7 +40,7 @@ public: nsHTTPSHandler(void); virtual ~nsHTTPSHandler(); - static NS_METHOD Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult); + nsresult Init(); //Functions from nsIProtocolHandler /* @@ -54,17 +54,6 @@ public: return NS_OK; }; - /* - The GetScheme function uniquely identifies the scheme this handler - is associated with. - */ - NS_IMETHOD GetScheme(char * *o_Scheme) - { - static const char* scheme = "https"; - *o_Scheme = nsCRT::strdup(scheme); - return NS_OK; - }; - /** * Called to create a transport from RequestTransport to accually * make a new channel. diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index 87e46b2b823..1f1be0a13a2 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -30,8 +30,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); //////////////////////////////////////////////////////////////////////////////// nsJARURI::nsJARURI() - : mJAREntry(nsnull), - mSchemeType(nsIURI::JAR) + : mJAREntry(nsnull) { NS_INIT_REFCNT(); } @@ -116,7 +115,6 @@ nsJARURI::SetSpec(const char * aSpec) if (nsCRT::strncmp("jar", &aSpec[startPos], endPos - startPos - 1) != 0) return NS_ERROR_MALFORMED_URI; - mSchemeType = nsIURI::JAR; // Search backward from the end for the "!/" delimiter. Remember, jar URLs // can nest, e.g.: // jar:jar:http://www.foo.com/bar.jar!/a.jar!/b.html @@ -277,12 +275,16 @@ nsJARURI::Equals(nsIURI *other, PRBool *result) } NS_IMETHODIMP -nsJARURI::SchemeIs(PRUint32 i_Scheme, PRBool *o_Equals) +nsJARURI::SchemeIs(const char *i_Scheme, PRBool *o_Equals) { NS_ENSURE_ARG_POINTER(o_Equals); - if (i_Scheme == nsIURI::UNKNOWN) - return NS_ERROR_INVALID_ARG; - *o_Equals = (mSchemeType == i_Scheme); + if (!i_Scheme) return NS_ERROR_INVALID_ARG; + + if (*i_Scheme == 'j' || *i_Scheme == 'J') { + *o_Equals = PL_strcasecmp("jar", i_Scheme) ? PR_FALSE : PR_TRUE; + } else { + *o_Equals = PR_FALSE; + } return NS_OK; } diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.h b/mozilla/netwerk/protocol/jar/src/nsJARURI.h index d45d56e51e8..fbbc9e96286 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.h +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.h @@ -50,7 +50,6 @@ public: protected: nsCOMPtr mJARFile; char *mJAREntry; - PRUint32 mSchemeType; }; #endif // nsJARURI_h__ diff --git a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 7b6204b5e6e..84f777f43fa 100644 --- a/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/mozilla/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -281,7 +281,7 @@ void nsUnknownDecoder::DetermineContentType(nsIRequest* request) nsCOMPtr pURL; if (NS_SUCCEEDED(aChannel->GetURI(getter_AddRefs(pURL)))) - pURL->SchemeIs(nsIURI::FILE, &isLocalFile); + pURL->SchemeIs("file", &isLocalFile); } if (!mRequireHTMLsuffix || !isLocalFile) {