Bug 783562 - blob: protocol wrong Content-Type header. r=sicking

This commit is contained in:
Andrea Marchesini 2012-08-27 19:34:30 -04:00
parent 8da33ddcbd
commit db9770f171
3 changed files with 23 additions and 2 deletions

View File

@ -77,6 +77,7 @@
#include "DictionaryHelpers.h" #include "DictionaryHelpers.h"
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsIPermissionManager.h" #include "nsIPermissionManager.h"
#include "nsMimeTypes.h"
#include "nsWrapperCacheInlines.h" #include "nsWrapperCacheInlines.h"
#include "nsStreamListenerWrapper.h" #include "nsStreamListenerWrapper.h"
@ -3087,9 +3088,15 @@ nsXMLHttpRequest::Send(nsIVariant* aVariant, const Nullable<RequestBody>& aBody)
} }
// Since we expect XML data, set the type hint accordingly // Since we expect XML data, set the type hint accordingly
// if the channel doesn't know any content type.
// This means that we always try to parse local files as XML // This means that we always try to parse local files as XML
// ignoring return value, as this is not critical // ignoring return value, as this is not critical
mChannel->SetContentType(NS_LITERAL_CSTRING("application/xml")); nsCAutoString contentType;
if (NS_FAILED(mChannel->GetContentType(contentType)) ||
contentType.IsEmpty() ||
contentType.Equals(UNKNOWN_CONTENT_TYPE)) {
mChannel->SetContentType(NS_LITERAL_CSTRING("application/xml"));
}
// We're about to send the request. Start our timeout. // We're about to send the request. Start our timeout.
mRequestSentTime = PR_Now(); mRequestSentTime = PR_Now();

View File

@ -189,7 +189,8 @@ nsJARInputThunk::IsNonBlocking(bool *nonBlocking)
nsJARChannel::nsJARChannel() nsJARChannel::nsJARChannel()
: mAppURI(nullptr) : mOpened(false)
, mAppURI(nullptr)
, mContentLength(-1) , mContentLength(-1)
, mLoadFlags(LOAD_NORMAL) , mLoadFlags(LOAD_NORMAL)
, mStatus(NS_OK) , mStatus(NS_OK)
@ -581,7 +582,15 @@ nsJARChannel::GetSecurityInfo(nsISupports **aSecurityInfo)
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::GetContentType(nsACString &result) nsJARChannel::GetContentType(nsACString &result)
{ {
// If the Jar file has not been open yet,
// We return application/x-unknown-content-type
if (!mOpened) {
result.Assign(UNKNOWN_CONTENT_TYPE);
return NS_OK;
}
if (mContentType.IsEmpty()) { if (mContentType.IsEmpty()) {
// //
// generate content type and set it // generate content type and set it
// //
@ -710,6 +719,8 @@ nsJARChannel::Open(nsIInputStream **stream)
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
NS_ADDREF(*stream = mJarInput); NS_ADDREF(*stream = mJarInput);
mOpened = true;
return NS_OK; return NS_OK;
} }
@ -754,6 +765,7 @@ nsJARChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
if (mLoadGroup) if (mLoadGroup)
mLoadGroup->AddRequest(this, nullptr); mLoadGroup->AddRequest(this, nullptr);
mOpened = true;
return NS_OK; return NS_OK;
} }

View File

@ -53,6 +53,8 @@ private:
nsCString mSpec; nsCString mSpec;
#endif #endif
bool mOpened;
nsCOMPtr<nsIJARURI> mJarURI; nsCOMPtr<nsIJARURI> mJarURI;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mAppURI; nsCOMPtr<nsIURI> mAppURI;