This commit is contained in:
Dan Witte 2010-08-30 13:20:39 -07:00
Родитель 03a104a7e0
Коммит 34d3553dfc
24 изменённых файлов: 104 добавлений и 65 удалений

Просмотреть файл

@ -2407,8 +2407,8 @@ NOT_IMPLEMENTED_IF_FUNC_1(GetContentType, nsACString &value)
NOT_IMPLEMENTED_IF_FUNC_1(SetContentType, const nsACString &value) NOT_IMPLEMENTED_IF_FUNC_1(SetContentType, const nsACString &value)
NOT_IMPLEMENTED_IF_FUNC_1(GetContentCharset, nsACString &value) NOT_IMPLEMENTED_IF_FUNC_1(GetContentCharset, nsACString &value)
NOT_IMPLEMENTED_IF_FUNC_1(SetContentCharset, const nsACString &value) NOT_IMPLEMENTED_IF_FUNC_1(SetContentCharset, const nsACString &value)
NOT_IMPLEMENTED_IF_FUNC_1(GetContentLength, PRInt64 *value) NOT_IMPLEMENTED_IF_FUNC_1(GetContentLength, PRInt32 *value)
NOT_IMPLEMENTED_IF_FUNC_1(SetContentLength, PRInt64 value) NOT_IMPLEMENTED_IF_FUNC_1(SetContentLength, PRInt32 value)
NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval) NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval)
NOT_IMPLEMENTED_IF_FUNC_2(AsyncOpen, nsIStreamListener *listener, NOT_IMPLEMENTED_IF_FUNC_2(AsyncOpen, nsIStreamListener *listener,
nsISupports *context) nsISupports *context)

Просмотреть файл

@ -265,13 +265,13 @@ nsWyciwygChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWyciwygChannel::GetContentLength(PRInt64 *aContentLength) nsWyciwygChannel::GetContentLength(PRInt32 *aContentLength)
{ {
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsWyciwygChannel::SetContentLength(PRInt64 aContentLength) nsWyciwygChannel::SetContentLength(PRInt32 aContentLength)
{ {
mContentLength = aContentLength; mContentLength = aContentLength;
@ -506,9 +506,10 @@ nsWyciwygChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctx,
rv = mListener->OnDataAvailable(this, mListenerContext, input, offset, count); rv = mListener->OnDataAvailable(this, mListenerContext, input, offset, count);
// XXX handle 64-bit stuff for real
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND)) if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, PRUint64(offset + count), mProgressSink->OnProgress(this, nsnull, PRUint64(offset + count),
mContentLength); PRUint64(mContentLength));
return rv; // let the pump cancel on failure return rv; // let the pump cancel on failure
} }

Просмотреть файл

@ -94,7 +94,7 @@ protected:
PRPackedBool mNeedToWriteCharset; PRPackedBool mNeedToWriteCharset;
PRInt32 mCharsetSource; PRInt32 mCharsetSource;
nsCString mCharset; nsCString mCharset;
PRInt64 mContentLength; PRInt32 mContentLength;
PRUint32 mLoadFlags; PRUint32 mLoadFlags;
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;

Просмотреть файл

@ -1012,13 +1012,13 @@ nsJSChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJSChannel::GetContentLength(PRInt64 *aContentLength) nsJSChannel::GetContentLength(PRInt32 *aContentLength)
{ {
return mStreamChannel->GetContentLength(aContentLength); return mStreamChannel->GetContentLength(aContentLength);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJSChannel::SetContentLength(PRInt64 aContentLength) nsJSChannel::SetContentLength(PRInt32 aContentLength)
{ {
return mStreamChannel->SetContentLength(aContentLength); return mStreamChannel->SetContentLength(aContentLength);
} }

Просмотреть файл

@ -112,7 +112,7 @@ public:
NS_IF_ADDREF(*result = mJarReader); NS_IF_ADDREF(*result = mJarReader);
} }
PRInt64 GetContentLength() PRInt32 GetContentLength()
{ {
return mContentLength; return mContentLength;
} }
@ -127,7 +127,7 @@ private:
nsCString mJarDirSpec; nsCString mJarDirSpec;
nsCOMPtr<nsIInputStream> mJarStream; nsCOMPtr<nsIInputStream> mJarStream;
nsCString mJarEntry; nsCString mJarEntry;
PRInt64 mContentLength; PRInt32 mContentLength;
}; };
NS_IMPL_THREADSAFE_ISUPPORTS1(nsJARInputThunk, nsIInputStream) NS_IMPL_THREADSAFE_ISUPPORTS1(nsJARInputThunk, nsIInputStream)
@ -173,11 +173,8 @@ nsJARInputThunk::EnsureJarStream()
} }
// ask the JarStream for the content length // ask the JarStream for the content length
// XXX want a 64-bit value from nsIInputStream::Available() rv = mJarStream->Available((PRUint32 *) &mContentLength);
PRUint32 contentLength;
rv = mJarStream->Available(&contentLength);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
mContentLength = contentLength;
return NS_OK; return NS_OK;
} }
@ -632,7 +629,7 @@ nsJARChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::GetContentLength(PRInt64 *result) nsJARChannel::GetContentLength(PRInt32 *result)
{ {
// if content length is unknown, query mJarInput... // if content length is unknown, query mJarInput...
if (mContentLength < 0 && mJarInput) if (mContentLength < 0 && mJarInput)
@ -643,7 +640,7 @@ nsJARChannel::GetContentLength(PRInt64 *result)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::SetContentLength(PRInt64 aContentLength) nsJARChannel::SetContentLength(PRInt32 aContentLength)
{ {
// XXX does this really make any sense at all? // XXX does this really make any sense at all?
mContentLength = aContentLength; mContentLength = aContentLength;
@ -905,14 +902,14 @@ nsJARChannel::OnDataAvailable(nsIRequest *req, nsISupports *ctx,
nsresult rv; nsresult rv;
// XXX want 64-bit values in OnDataAvailable
rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count); rv = mListener->OnDataAvailable(this, mListenerContext, stream, offset, count);
// simply report progress here instead of hooking ourselves up as a // simply report progress here instead of hooking ourselves up as a
// nsITransportEventSink implementation. // nsITransportEventSink implementation.
// XXX do the 64-bit stuff for real
if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND)) if (mProgressSink && NS_SUCCEEDED(rv) && !(mLoadFlags & LOAD_BACKGROUND))
mProgressSink->OnProgress(this, nsnull, PRUint64(offset + count), mProgressSink->OnProgress(this, nsnull, PRUint64(offset + count),
mContentLength); PRUint64(mContentLength));
return rv; // let the pump cancel on failure return rv; // let the pump cancel on failure
} }

Просмотреть файл

@ -96,7 +96,7 @@ private:
nsCOMPtr<nsISupports> mListenerContext; nsCOMPtr<nsISupports> mListenerContext;
nsCString mContentType; nsCString mContentType;
nsCString mContentCharset; nsCString mContentCharset;
PRInt64 mContentLength; PRInt32 mContentLength;
PRUint32 mLoadFlags; PRUint32 mLoadFlags;
nsresult mStatus; nsresult mStatus;
PRPackedBool mIsPending; PRPackedBool mIsPending;

Просмотреть файл

@ -407,13 +407,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt64 aContentLength) NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_NOTREACHED("nsIconChannel::SetContentLength"); NS_NOTREACHED("nsIconChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -69,7 +69,7 @@ public:
protected: protected:
nsCOMPtr<nsIURI> mUrl; nsCOMPtr<nsIURI> mUrl;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
PRInt64 mContentLength; PRInt32 mContentLength;
nsCOMPtr<nsILoadGroup> mLoadGroup; nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsISupports> mOwner; nsCOMPtr<nsISupports> mOwner;

Просмотреть файл

@ -399,13 +399,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt64 aContentLength) NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_NOTREACHED("nsIconChannel::SetContentLength"); NS_NOTREACHED("nsIconChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -636,13 +636,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt64 aContentLength) NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_NOTREACHED("nsIconChannel::SetContentLength"); NS_NOTREACHED("nsIconChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -70,7 +70,7 @@ public:
protected: protected:
nsCOMPtr<nsIURI> mUrl; nsCOMPtr<nsIURI> mUrl;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
PRInt64 mContentLength; PRInt32 mContentLength;
nsCOMPtr<nsILoadGroup> mLoadGroup; nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsISupports> mOwner; nsCOMPtr<nsISupports> mOwner;

Просмотреть файл

@ -693,13 +693,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt64 aContentLength) NS_IMETHODIMP nsIconChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_NOTREACHED("nsIconChannel::SetContentLength"); NS_NOTREACHED("nsIconChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -72,7 +72,7 @@ public:
protected: protected:
nsCOMPtr<nsIURI> mUrl; nsCOMPtr<nsIURI> mUrl;
nsCOMPtr<nsIURI> mOriginalURI; nsCOMPtr<nsIURI> mOriginalURI;
PRInt64 mContentLength; PRInt32 mContentLength;
nsCOMPtr<nsILoadGroup> mLoadGroup; nsCOMPtr<nsILoadGroup> mLoadGroup;
nsCOMPtr<nsIInterfaceRequestor> mCallbacks; nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
nsCOMPtr<nsISupports> mOwner; nsCOMPtr<nsISupports> mOwner;

Просмотреть файл

@ -50,6 +50,14 @@
*/ */
/**
* Content-Length of a channel. Used instead of the nsIChannel.contentLength
* property.
* Not available before onStartRequest has been called.
* Type: PRUint64
*/
#define NS_CHANNEL_PROP_CONTENT_LENGTH_STR "content-length"
/** /**
* MIME Content-Disposition header of channel. * MIME Content-Disposition header of channel.
* Not available before onStartRequest. * Not available before onStartRequest.
@ -65,9 +73,12 @@
#define NS_CHANNEL_PROP_CHANNEL_POLICY_STR "channel-policy" #define NS_CHANNEL_PROP_CHANNEL_POLICY_STR "channel-policy"
#ifdef IMPL_NS_NET #ifdef IMPL_NS_NET
#define NS_CHANNEL_PROP_CONTENT_LENGTH gNetStrings->kContentLength
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION gNetStrings->kContentDisposition #define NS_CHANNEL_PROP_CONTENT_DISPOSITION gNetStrings->kContentDisposition
#define NS_CHANNEL_PROP_CHANNEL_POLICY gNetStrings->kChannelPolicy #define NS_CHANNEL_PROP_CHANNEL_POLICY gNetStrings->kChannelPolicy
#else #else
#define NS_CHANNEL_PROP_CONTENT_LENGTH \
NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_LENGTH_STR)
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION \ #define NS_CHANNEL_PROP_CONTENT_DISPOSITION \
NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR) NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR)
#define NS_CHANNEL_PROP_CHANNEL_POLICY \ #define NS_CHANNEL_PROP_CHANNEL_POLICY \

Просмотреть файл

@ -47,6 +47,8 @@ class nsNetStrings {
public: public:
nsNetStrings(); nsNetStrings();
/** "content-length" */
const nsLiteralString kContentLength;
const nsLiteralString kContentDisposition; const nsLiteralString kContentDisposition;
const nsLiteralString kChannelPolicy; const nsLiteralString kChannelPolicy;
}; };

Просмотреть файл

@ -86,8 +86,7 @@ private:
// nsBaseChannel // nsBaseChannel
nsBaseChannel::nsBaseChannel() nsBaseChannel::nsBaseChannel()
: mContentLength(-1) : mLoadFlags(LOAD_NORMAL)
, mLoadFlags(LOAD_NORMAL)
, mStatus(NS_OK) , mStatus(NS_OK)
, mQueriedProgressSink(PR_TRUE) , mQueriedProgressSink(PR_TRUE)
, mSynthProgressEvents(PR_FALSE) , mSynthProgressEvents(PR_FALSE)
@ -186,6 +185,23 @@ nsBaseChannel::HasContentTypeHint() const
return !mContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE); return !mContentType.EqualsLiteral(UNKNOWN_CONTENT_TYPE);
} }
void
nsBaseChannel::SetContentLength64(PRInt64 len)
{
// XXX: Storing the content-length as a property may not be what we want.
// It has the drawback of being copied if we redirect this channel.
// Maybe it is time for nsIChannel2.
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, len);
}
PRInt64
nsBaseChannel::ContentLength64()
{
PRInt64 len;
nsresult rv = GetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH, &len);
return NS_SUCCEEDED(rv) ? len : -1;
}
nsresult nsresult
nsBaseChannel::PushStreamConverter(const char *fromType, nsBaseChannel::PushStreamConverter(const char *fromType,
const char *toType, const char *toType,
@ -206,7 +222,7 @@ nsBaseChannel::PushStreamConverter(const char *fromType,
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mListener = converter; mListener = converter;
if (invalidatesContentLength) if (invalidatesContentLength)
mContentLength = -1; SetContentLength64(-1);
if (result) { if (result) {
*result = nsnull; *result = nsnull;
converter.swap(*result); converter.swap(*result);
@ -504,16 +520,20 @@ nsBaseChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBaseChannel::GetContentLength(PRInt64 *aContentLength) nsBaseChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; PRInt64 len = ContentLength64();
if (len > PR_INT32_MAX || len < 0)
*aContentLength = -1;
else
*aContentLength = (PRInt32) len;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsBaseChannel::SetContentLength(PRInt64 aContentLength) nsBaseChannel::SetContentLength(PRInt32 aContentLength)
{ {
mContentLength = aContentLength; SetContentLength64(aContentLength);
return NS_OK; return NS_OK;
} }
@ -735,7 +755,8 @@ nsBaseChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
offset, count); offset, count);
if (mSynthProgressEvents && NS_SUCCEEDED(rv)) { if (mSynthProgressEvents && NS_SUCCEEDED(rv)) {
PRUint64 prog = PRUint64(offset) + count; PRUint64 prog = PRUint64(offset) + count;
OnTransportStatus(nsnull, nsITransport::STATUS_READING, prog, mContentLength); PRUint64 progMax = ContentLength64();
OnTransportStatus(nsnull, nsITransport::STATUS_READING, prog, progMax);
} }
return rv; return rv;

Просмотреть файл

@ -185,11 +185,10 @@ public:
return mPump || mWaitingOnAsyncRedirect; return mPump || mWaitingOnAsyncRedirect;
} }
// Get or set the content length that should be reported for this channel. -1 // Set the content length that should be reported for this channel. Pass -1
// indicates an unspecified content length. // to indicate an unspecified content length.
PRInt64& ContentLength() { void SetContentLength64(PRInt64 len);
return mContentLength; PRInt64 ContentLength64();
}
// Helper function for querying the channel's notification callbacks. // Helper function for querying the channel's notification callbacks.
template <class T> void GetCallback(nsCOMPtr<T> &result) { template <class T> void GetCallback(nsCOMPtr<T> &result) {
@ -290,7 +289,6 @@ private:
nsCOMPtr<nsIChannel> mRedirectChannel; nsCOMPtr<nsIChannel> mRedirectChannel;
nsCString mContentType; nsCString mContentType;
nsCString mContentCharset; nsCString mContentCharset;
PRInt64 mContentLength;
PRUint32 mLoadFlags; PRUint32 mLoadFlags;
nsresult mStatus; nsresult mStatus;
PRPackedBool mQueriedProgressSink; PRPackedBool mQueriedProgressSink;

Просмотреть файл

@ -40,7 +40,8 @@
NS_HIDDEN_(nsNetStrings*) gNetStrings; NS_HIDDEN_(nsNetStrings*) gNetStrings;
nsNetStrings::nsNetStrings() nsNetStrings::nsNetStrings()
: NS_LITERAL_STRING_INIT(kContentDisposition, NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR), : NS_LITERAL_STRING_INIT(kContentLength, NS_CHANNEL_PROP_CONTENT_LENGTH_STR),
NS_LITERAL_STRING_INIT(kContentDisposition, NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR),
NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR) NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
{} {}

Просмотреть файл

@ -359,17 +359,20 @@ HttpBaseChannel::SetContentCharset(const nsACString& aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
HttpBaseChannel::GetContentLength(PRInt64 *aContentLength) HttpBaseChannel::GetContentLength(PRInt32 *aContentLength)
{ {
NS_ENSURE_ARG_POINTER(aContentLength);
if (!mResponseHead) if (!mResponseHead)
return NS_ERROR_NOT_AVAILABLE; return NS_ERROR_NOT_AVAILABLE;
// XXX truncates to 32 bit
*aContentLength = mResponseHead->ContentLength(); *aContentLength = mResponseHead->ContentLength();
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
HttpBaseChannel::SetContentLength(PRInt64 value) HttpBaseChannel::SetContentLength(PRInt32 value)
{ {
NS_NOTYETIMPLEMENTED("nsHttpChannel::SetContentLength"); NS_NOTYETIMPLEMENTED("nsHttpChannel::SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;

Просмотреть файл

@ -129,8 +129,8 @@ public:
NS_IMETHOD SetContentType(const nsACString& aContentType); NS_IMETHOD SetContentType(const nsACString& aContentType);
NS_IMETHOD GetContentCharset(nsACString& aContentCharset); NS_IMETHOD GetContentCharset(nsACString& aContentCharset);
NS_IMETHOD SetContentCharset(const nsACString& aContentCharset); NS_IMETHOD SetContentCharset(const nsACString& aContentCharset);
NS_IMETHOD GetContentLength(PRInt64 *aContentLength); NS_IMETHOD GetContentLength(PRInt32 *aContentLength);
NS_IMETHOD SetContentLength(PRInt64 aContentLength); NS_IMETHOD SetContentLength(PRInt32 aContentLength);
NS_IMETHOD Open(nsIInputStream **aResult); NS_IMETHOD Open(nsIInputStream **aResult);
// HttpBaseChannel::nsIHttpChannel // HttpBaseChannel::nsIHttpChannel

Просмотреть файл

@ -763,6 +763,10 @@ nsHttpChannel::CallOnStartRequest()
if (mResponseHead && mResponseHead->ContentCharset().IsEmpty()) if (mResponseHead && mResponseHead->ContentCharset().IsEmpty())
mResponseHead->SetContentCharset(mContentCharsetHint); mResponseHead->SetContentCharset(mContentCharsetHint);
if (mResponseHead)
SetPropertyAsInt64(NS_CHANNEL_PROP_CONTENT_LENGTH,
mResponseHead->ContentLength());
// Allow consumers to override our content type // Allow consumers to override our content type
if ((mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) && if ((mLoadFlags & LOAD_CALL_CONTENT_SNIFFERS) &&
gIOService->GetContentSniffers().Count() != 0) { gIOService->GetContentSniffers().Count() != 0) {
@ -2459,16 +2463,16 @@ nsHttpChannel::CheckCache()
// size of the cached content, then the cached response is partial... // size of the cached content, then the cached response is partial...
// either we need to issue a byte range request or we need to refetch // either we need to issue a byte range request or we need to refetch
// the entire document. // the entire document.
PRInt64 contentLength = mCachedResponseHead->ContentLength(); nsInt64 contentLength = mCachedResponseHead->ContentLength();
if (contentLength != -1) { if (contentLength != nsInt64(-1)) {
PRUint32 size; PRUint32 size;
rv = mCacheEntry->GetDataSize(&size); rv = mCacheEntry->GetDataSize(&size);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
if (PRInt64(size) != contentLength) { if (nsInt64(size) != contentLength) {
LOG(("Cached data size does not match the Content-Length header " LOG(("Cached data size does not match the Content-Length header "
"[content-length=%lld size=%u]\n", contentLength, size)); "[content-length=%lld size=%u]\n", PRInt64(contentLength), size));
if ((PRInt64(size) < contentLength) && mCachedResponseHead->IsResumable()) { if ((nsInt64(size) < contentLength) && mCachedResponseHead->IsResumable()) {
// looks like a partial entry. // looks like a partial entry.
rv = SetupByteRangeRequest(size); rv = SetupByteRangeRequest(size);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@ -4069,7 +4073,7 @@ nsHttpChannel::OnDataAvailable(nsIRequest *request, nsISupports *ctxt,
// of a byte range request, the content length stored in the cached // of a byte range request, the content length stored in the cached
// response headers is what we want to use here. // response headers is what we want to use here.
PRUint64 progressMax(mResponseHead->ContentLength()); PRUint64 progressMax(PRUint64(mResponseHead->ContentLength()));
PRUint64 progress = mLogicalOffset + PRUint64(count); PRUint64 progress = mLogicalOffset + PRUint64(count);
NS_ASSERTION(progress <= progressMax, "unexpected progress values"); NS_ASSERTION(progress <= progressMax, "unexpected progress values");

Просмотреть файл

@ -370,7 +370,7 @@ nsViewSourceChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength) nsViewSourceChannel::GetContentLength(PRInt32 *aContentLength)
{ {
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);
@ -378,7 +378,7 @@ nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsViewSourceChannel::SetContentLength(PRInt64 aContentLength) nsViewSourceChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE); NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);

Просмотреть файл

@ -37,6 +37,7 @@
#include "nsMultiMixedConv.h" #include "nsMultiMixedConv.h"
#include "nsMemory.h" #include "nsMemory.h"
#include "nsInt64.h"
#include "plstr.h" #include "plstr.h"
#include "nsIHttpChannel.h" #include "nsIHttpChannel.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
@ -323,14 +324,14 @@ nsPartChannel::SetContentCharset(const nsACString &aContentCharset)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPartChannel::GetContentLength(PRInt64 *aContentLength) nsPartChannel::GetContentLength(PRInt32 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength; // XXX truncates 64-bit value
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsPartChannel::SetContentLength(PRInt64 aContentLength) nsPartChannel::SetContentLength(PRInt32 aContentLength)
{ {
mContentLength = aContentLength; mContentLength = aContentLength;
return NS_OK; return NS_OK;
@ -796,7 +797,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
rv = mPartChannel->SetContentType(mContentType); rv = mPartChannel->SetContentType(mContentType);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = mPartChannel->SetContentLength(mContentLength); rv = mPartChannel->SetContentLength(mContentLength); // XXX Truncates 64-bit!
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = mPartChannel->SetContentDisposition(mContentDisposition); rv = mPartChannel->SetContentDisposition(mContentDisposition);
@ -938,7 +939,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
if (headerStr.LowerCaseEqualsLiteral("content-type")) { if (headerStr.LowerCaseEqualsLiteral("content-type")) {
mContentType = headerVal; mContentType = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("content-length")) { } else if (headerStr.LowerCaseEqualsLiteral("content-length")) {
PR_sscanf(headerVal.get(), "%lld", &mContentLength); mContentLength = atoi(headerVal.get()); // XXX 64-bit math?
} else if (headerStr.LowerCaseEqualsLiteral("content-disposition")) { } else if (headerStr.LowerCaseEqualsLiteral("content-disposition")) {
mContentDisposition = headerVal; mContentDisposition = headerVal;
} else if (headerStr.LowerCaseEqualsLiteral("set-cookie")) { } else if (headerStr.LowerCaseEqualsLiteral("set-cookie")) {
@ -979,7 +980,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr,
mIsByteRangeRequest = PR_TRUE; mIsByteRangeRequest = PR_TRUE;
if (mContentLength == LL_MAXUINT) if (mContentLength == LL_MAXUINT)
mContentLength = PRUint64(PRInt64(mByteRangeEnd - mByteRangeStart + 1)); mContentLength = PRUint64(PRInt64(mByteRangeEnd - mByteRangeStart + nsInt64(1)));
} }
} }
*newLine = tmpChar; *newLine = tmpChar;

Просмотреть файл

@ -247,14 +247,14 @@ NS_IMETHODIMP nsExtProtocolChannel::SetContentCharset(const nsACString &aContent
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt64 * aContentLength) NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt32 * aContentLength)
{ {
*aContentLength = -1; *aContentLength = -1;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsExtProtocolChannel::SetContentLength(PRInt64 aContentLength) nsExtProtocolChannel::SetContentLength(PRInt32 aContentLength)
{ {
NS_NOTREACHED("SetContentLength"); NS_NOTREACHED("SetContentLength");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;