Bug 632490: Use a content-type hint in mozJSSubScriptLoader::LoadSubScript. r=shaver a=blocking-fennec

--HG--
extra : rebase_source : ff4aba30c6ac11b97921c368d8220a63d698692d
This commit is contained in:
Matt Brubeck 2011-02-08 12:16:06 -08:00
parent ae544d7e57
commit 716e09f70f

View File

@ -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);