Bug 1199049 - Part 8: Use Necko-level CORS preflights in fetch; r=jdm

This commit is contained in:
Ehsan Akhgari 2015-08-27 14:41:58 -04:00
parent c9ef5ad84e
commit 57574d5cbd

View File

@ -618,18 +618,19 @@ FetchDriver::HttpFetch(bool aCORSFlag, bool aCORSPreflightFlag, bool aAuthentica
if (aCORSPreflightFlag) {
MOZ_ASSERT(mRequest->Mode() != RequestMode::No_cors,
"FetchDriver::ContinueFetch() should ensure that the request is not no-cors");
nsCOMPtr<nsIChannel> preflightChannel;
MOZ_ASSERT(httpChan, "CORS preflight can only be used with HTTP channels");
nsAutoTArray<nsCString, 5> unsafeHeaders;
mRequest->Headers()->GetUnsafeHeaders(unsafeHeaders);
rv = NS_StartCORSPreflight(chan, listener, mPrincipal,
useCredentials,
unsafeHeaders,
getter_AddRefs(preflightChannel));
} else {
rv = chan->AsyncOpen(listener, nullptr);
nsCOMPtr<nsIHttpChannelInternal> internalChan = do_QueryInterface(httpChan);
rv = internalChan->SetCorsPreflightParameters(unsafeHeaders, useCredentials, mPrincipal);
if (NS_WARN_IF(NS_FAILED(rv))) {
return FailWithNetworkError();
}
}
rv = chan->AsyncOpen(listener, nullptr);
if (NS_WARN_IF(NS_FAILED(rv))) {
return FailWithNetworkError();
}