From 716e09f70f55f15b657a9b87982d5c2af62b5b07 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 8 Feb 2011 12:16:06 -0800 Subject: [PATCH] Bug 632490: Use a content-type hint in mozJSSubScriptLoader::LoadSubScript. r=shaver a=blocking-fennec --HG-- extra : rebase_source : ff4aba30c6ac11b97921c368d8220a63d698692d --- .../xpconnect/loader/mozJSSubScriptLoader.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp b/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp index 10ccca21fb33..765b7b493064 100644 --- a/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp +++ b/js/src/xpconnect/loader/mozJSSubScriptLoader.cpp @@ -323,11 +323,18 @@ mozJSSubScriptLoader::LoadSubScript (const PRUnichar * aURL tmp.Append(uriStr); uriStr = tmp; - } - - rv = NS_OpenURI(getter_AddRefs(instream), uri, serv, - nsnull, nsnull, nsIRequest::LOAD_NORMAL, - getter_AddRefs(chan)); + } + + // Instead of calling NS_OpenURI, we create the channel ourselves and call + // SetContentType, to avoid expensive MIME type lookups (bug 632490). + rv = NS_NewChannel(getter_AddRefs(chan), uri, serv, + nsnull, nsnull, nsIRequest::LOAD_NORMAL); + if (NS_SUCCEEDED(rv)) + { + chan->SetContentType(NS_LITERAL_CSTRING("application/javascript")); + rv = chan->Open(getter_AddRefs(instream)); + } + if (NS_FAILED(rv)) { errmsg = JS_NewStringCopyZ (cx, LOAD_ERROR_NOSTREAM);