This commit is contained in:
Dan Witte 2010-08-27 08:04:00 -07:00
Родитель ff25b22c88 4b82318c32
Коммит 16a3298070
35 изменённых файлов: 147 добавлений и 123 удалений

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

@ -6718,14 +6718,11 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
} }
} }
} else { } else {
nsCOMPtr<nsIMultiPartChannel> partChannel = do_QueryInterface(aChannel); nsCAutoString contentDisp;
if (partChannel) { rv = aChannel->GetContentDisposition(contentDisp);
nsCAutoString contentDisp; if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) {
rv = partChannel->GetContentDisposition(contentDisp); SetHeaderData(nsGkAtoms::headerContentDisposition,
if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) { NS_ConvertASCIItoUTF16(contentDisp));
SetHeaderData(nsGkAtoms::headerContentDisposition,
NS_ConvertASCIItoUTF16(contentDisp));
}
} }
} }
} }

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

@ -2407,6 +2407,7 @@ 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(GetContentDisposition, nsACString &value)
NOT_IMPLEMENTED_IF_FUNC_1(GetContentLength, PRInt64 *value) NOT_IMPLEMENTED_IF_FUNC_1(GetContentLength, PRInt64 *value)
NOT_IMPLEMENTED_IF_FUNC_1(SetContentLength, PRInt64 value) NOT_IMPLEMENTED_IF_FUNC_1(SetContentLength, PRInt64 value)
NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval) NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval)

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

@ -264,6 +264,13 @@ nsWyciwygChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP
nsWyciwygChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsWyciwygChannel::GetContentLength(PRInt64 *aContentLength) nsWyciwygChannel::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -121,7 +121,9 @@ parent:
__delete__(); __delete__();
PExternalHelperApp(URI uri, nsCString aMimeContentType, bool aForceSave, PRInt64 aContentLength); PExternalHelperApp(URI uri, nsCString aMimeContentType,
nsCString aContentDisposition, bool aForceSave,
PRInt64 aContentLength);
child: child:
CreateWidget(MagicWindowHandle parentWidget); CreateWidget(MagicWindowHandle parentWidget);

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

@ -1252,6 +1252,7 @@ TabChildGlobal::GetPrincipal()
PExternalHelperAppChild* PExternalHelperAppChild*
TabChild::AllocPExternalHelperApp(const IPC::URI& uri, TabChild::AllocPExternalHelperApp(const IPC::URI& uri,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const bool& aForceSave, const bool& aForceSave,
const PRInt64& aContentLength) const PRInt64& aContentLength)
{ {

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

@ -227,6 +227,7 @@ public:
virtual PExternalHelperAppChild *AllocPExternalHelperApp( virtual PExternalHelperAppChild *AllocPExternalHelperApp(
const IPC::URI& uri, const IPC::URI& uri,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const bool& aForceSave, const bool& aForceSave,
const PRInt64& aContentLength); const PRInt64& aContentLength);
virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService); virtual bool DeallocPExternalHelperApp(PExternalHelperAppChild *aService);

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

@ -811,12 +811,13 @@ TabParent::GetFrameLoader() const
PExternalHelperAppParent* PExternalHelperAppParent*
TabParent::AllocPExternalHelperApp(const IPC::URI& uri, TabParent::AllocPExternalHelperApp(const IPC::URI& uri,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const bool& aForceSave, const bool& aForceSave,
const PRInt64& aContentLength) const PRInt64& aContentLength)
{ {
ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength); ExternalHelperAppParent *parent = new ExternalHelperAppParent(uri, aContentLength);
parent->AddRef(); parent->AddRef();
parent->Init(this, aMimeContentType, aForceSave); parent->Init(this, aMimeContentType, aContentDisposition, aForceSave);
return parent; return parent;
} }

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

@ -150,6 +150,7 @@ public:
virtual PExternalHelperAppParent* AllocPExternalHelperApp( virtual PExternalHelperAppParent* AllocPExternalHelperApp(
const IPC::URI& uri, const IPC::URI& uri,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const bool& aForceSave, const bool& aForceSave,
const PRInt64& aContentLength); const PRInt64& aContentLength);
virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService); virtual bool DeallocPExternalHelperApp(PExternalHelperAppParent* aService);

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

@ -1011,6 +1011,12 @@ nsJSChannel::SetContentCharset(const nsACString &aContentCharset)
return mStreamChannel->SetContentCharset(aContentCharset); return mStreamChannel->SetContentCharset(aContentCharset);
} }
NS_IMETHODIMP
nsJSChannel::GetContentDisposition(nsACString &aContentDisposition)
{
return mStreamChannel->GetContentDisposition(aContentDisposition);
}
NS_IMETHODIMP NS_IMETHODIMP
nsJSChannel::GetContentLength(PRInt64 *aContentLength) nsJSChannel::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -631,6 +631,13 @@ nsJARChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsJARChannel::GetContentDisposition(nsACString &result)
{
result = mContentDisposition;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsJARChannel::GetContentLength(PRInt64 *result) nsJARChannel::GetContentLength(PRInt64 *result)
{ {
@ -771,7 +778,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
} }
if (NS_SUCCEEDED(status) && channel) { if (NS_SUCCEEDED(status) && channel) {
nsCAutoString header;
// Grab the security info from our base channel // Grab the security info from our base channel
channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo)); channel->GetSecurityInfo(getter_AddRefs(mSecurityInfo));
@ -780,6 +786,7 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
// We only want to run scripts if the server really intended to // We only want to run scripts if the server really intended to
// send us a JAR file. Check the server-supplied content type for // send us a JAR file. Check the server-supplied content type for
// a JAR type. // a JAR type.
nsCAutoString header;
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"), httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"),
header); header);
nsCAutoString contentType; nsCAutoString contentType;
@ -790,10 +797,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
mIsUnsafe = !(contentType.Equals(channelContentType) && mIsUnsafe = !(contentType.Equals(channelContentType) &&
(contentType.EqualsLiteral("application/java-archive") || (contentType.EqualsLiteral("application/java-archive") ||
contentType.EqualsLiteral("application/x-jar"))); contentType.EqualsLiteral("application/x-jar")));
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Disposition"),
header);
if (NS_SUCCEEDED(rv))
SetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION, header);
} else { } else {
nsCOMPtr<nsIJARChannel> innerJARChannel(do_QueryInterface(channel)); nsCOMPtr<nsIJARChannel> innerJARChannel(do_QueryInterface(channel));
if (innerJARChannel) { if (innerJARChannel) {
@ -801,11 +804,9 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader,
innerJARChannel->GetIsUnsafe(&unsafe); innerJARChannel->GetIsUnsafe(&unsafe);
mIsUnsafe = unsafe; mIsUnsafe = unsafe;
} }
// Soon-to-be common way to get Disposition: right now only nsIJARChannel
rv = NS_GetContentDisposition(request, header);
if (NS_SUCCEEDED(rv))
SetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION, header);
} }
channel->GetContentDisposition(mContentDisposition);
} }
if (NS_SUCCEEDED(status) && mIsUnsafe) { if (NS_SUCCEEDED(status) && mIsUnsafe) {

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

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

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

@ -407,6 +407,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;

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

@ -399,6 +399,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;

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

@ -636,6 +636,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;

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

@ -693,6 +693,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
NS_IMETHODIMP
nsIconChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength)
{ {
*aContentLength = mContentLength; *aContentLength = mContentLength;

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

@ -973,11 +973,10 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
/* NS_WARNING if the content type from the channel isn't the same if the sniffing */ /* NS_WARNING if the content type from the channel isn't the same if the sniffing */
#endif #endif
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
if (mContentType.IsEmpty()) { if (mContentType.IsEmpty()) {
LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |sniffing of mimetype failed|"); LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |sniffing of mimetype failed|");
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
rv = NS_ERROR_FAILURE; rv = NS_ERROR_FAILURE;
if (chan) { if (chan) {
rv = chan->GetContentType(mContentType); rv = chan->GetContentType(mContentType);
@ -1017,14 +1016,8 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
/* set our content disposition as a property */ /* set our content disposition as a property */
nsCAutoString disposition; nsCAutoString disposition;
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest)); if (chan) {
if (httpChannel) { chan->GetContentDisposition(disposition);
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), disposition);
} else {
nsCOMPtr<nsIMultiPartChannel> multiPartChannel(do_QueryInterface(aRequest));
if (multiPartChannel) {
multiPartChannel->GetContentDisposition(disposition);
}
} }
if (!disposition.IsEmpty()) { if (!disposition.IsEmpty()) {
nsCOMPtr<nsISupportsCString> contentDisposition(do_CreateInstance("@mozilla.org/supports-cstring;1")); nsCOMPtr<nsISupportsCString> contentDisposition(do_CreateInstance("@mozilla.org/supports-cstring;1"));
@ -1084,6 +1077,7 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx
if (imageType == imgIContainer::TYPE_RASTER) { if (imageType == imgIContainer::TYPE_RASTER) {
/* Use content-length as a size hint for http channels. */ /* Use content-length as a size hint for http channels. */
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
if (httpChannel) { if (httpChannel) {
PRInt64 contentLength; PRInt64 contentLength;
rv = httpChannel->GetContentLength(&contentLength); rv = httpChannel->GetContentLength(&contentLength);

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

@ -50,13 +50,6 @@
*/ */
/**
* MIME Content-Disposition header of channel.
* Not available before onStartRequest.
* Type: nsACString
*/
#define NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR "content-disposition"
/** /**
* Exists to allow content policy mechanism to function properly during channel * Exists to allow content policy mechanism to function properly during channel
* redirects. Contains security contextual information about the load. * redirects. Contains security contextual information about the load.
@ -65,11 +58,8 @@
#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_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_DISPOSITION \
NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR)
#define NS_CHANNEL_PROP_CHANNEL_POLICY \ #define NS_CHANNEL_PROP_CHANNEL_POLICY \
NS_LITERAL_STRING(NS_CHANNEL_PROP_CHANNEL_POLICY_STR) NS_LITERAL_STRING(NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
#endif #endif

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

@ -56,7 +56,7 @@ interface nsIStreamListener;
* *
* This interface must be used only from the XPCOM main thread. * This interface must be used only from the XPCOM main thread.
*/ */
[scriptable, uuid(e0bb5c49-c54e-4efb-8f0d-6a7edd926fab)] [scriptable, uuid(3906f857-3d79-4716-be55-ed2455d666f4)]
interface nsIChannel : nsIRequest interface nsIChannel : nsIRequest
{ {
/** /**
@ -157,6 +157,13 @@ interface nsIChannel : nsIRequest
*/ */
attribute PRInt64 contentLength; attribute PRInt64 contentLength;
/**
* Access to the Content-Disposition header if available and if applicable.
* This allows getting the preferred handling method, preferred filename,
* etc. See RFC 2183.
*/
readonly attribute ACString contentDisposition;
/** /**
* Synchronously open the channel. * Synchronously open the channel.
* *

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

@ -45,7 +45,7 @@ interface nsIChannel;
* associated with a MultiPartChannel. * associated with a MultiPartChannel.
*/ */
[scriptable, uuid(ba78db7b-b88c-4b76-baf9-3c2296a585ae)] [scriptable, uuid(51698f28-c975-4bce-a951-25130cda0113)]
interface nsIMultiPartChannel : nsISupports interface nsIMultiPartChannel : nsISupports
{ {
/** /**
@ -53,13 +53,6 @@ interface nsIMultiPartChannel : nsISupports
*/ */
readonly attribute nsIChannel baseChannel; readonly attribute nsIChannel baseChannel;
/**
* Access to the Content-Disposition header field of this part of
* a multipart message. This allows getting the preferred
* handling method, preferred filename, etc. See RFC 2183.
*/
attribute ACString contentDisposition;
/** /**
* Attribute guaranteed to be different for different parts of * Attribute guaranteed to be different for different parts of
* the same multipart document. * the same multipart document.

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

@ -47,7 +47,6 @@ class nsNetStrings {
public: public:
nsNetStrings(); nsNetStrings();
const nsLiteralString kContentDisposition;
const nsLiteralString kChannelPolicy; const nsLiteralString kChannelPolicy;
}; };

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

@ -238,19 +238,6 @@ NS_NewChannel(nsIChannel **result,
return rv; return rv;
} }
// For now, works only with JARChannel. Future: with all channels that may
// have Content-Disposition header (JAR, nsIHttpChannel, and nsIMultiPartChannel).
inline nsresult
NS_GetContentDisposition(nsIRequest *channel,
nsACString &result)
{
nsCOMPtr<nsIPropertyBag2> props(do_QueryInterface(channel));
if (props)
return props->GetPropertyAsACString(NS_CHANNEL_PROP_CONTENT_DISPOSITION,
result);
return NS_ERROR_NOT_AVAILABLE;
}
// Use this function with CAUTION. It creates a stream that blocks when you // Use this function with CAUTION. It creates a stream that blocks when you
// Read() from it and blocking the UI thread is a bad idea. If you don't want // Read() from it and blocking the UI thread is a bad idea. If you don't want
// to implement a full blown asynchronous consumer (via nsIStreamListener) look // to implement a full blown asynchronous consumer (via nsIStreamListener) look

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

@ -503,6 +503,13 @@ nsBaseChannel::SetContentCharset(const nsACString &aContentCharset)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsBaseChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition = mContentDisposition;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsBaseChannel::GetContentLength(PRInt64 *aContentLength) nsBaseChannel::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -290,6 +290,7 @@ private:
nsCOMPtr<nsIChannel> mRedirectChannel; nsCOMPtr<nsIChannel> mRedirectChannel;
nsCString mContentType; nsCString mContentType;
nsCString mContentCharset; nsCString mContentCharset;
nsCString mContentDisposition;
PRInt64 mContentLength; PRInt64 mContentLength;
PRUint32 mLoadFlags; PRUint32 mLoadFlags;
nsresult mStatus; nsresult mStatus;

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

@ -40,8 +40,7 @@
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(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
{} {}

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

@ -358,6 +358,18 @@ HttpBaseChannel::SetContentCharset(const nsACString& aContentCharset)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
HttpBaseChannel::GetContentDisposition(nsACString& aContentDisposition)
{
aContentDisposition.Truncate();
if (!mResponseHead)
return NS_ERROR_NOT_AVAILABLE;
mResponseHead->GetHeader(nsHttp::Content_Disposition, aContentDisposition);
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
HttpBaseChannel::GetContentLength(PRInt64 *aContentLength) HttpBaseChannel::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -129,6 +129,7 @@ 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 GetContentDisposition(nsACString& aContentDisposition);
NS_IMETHOD GetContentLength(PRInt64 *aContentLength); NS_IMETHOD GetContentLength(PRInt64 *aContentLength);
NS_IMETHOD SetContentLength(PRInt64 aContentLength); NS_IMETHOD SetContentLength(PRInt64 aContentLength);
NS_IMETHOD Open(nsIInputStream **aResult); NS_IMETHOD Open(nsIInputStream **aResult);

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

@ -369,6 +369,14 @@ nsViewSourceChannel::SetContentCharset(const nsACString &aContentCharset)
return mChannel->SetContentCharset(aContentCharset); return mChannel->SetContentCharset(aContentCharset);
} }
NS_IMETHODIMP
nsViewSourceChannel::GetContentDisposition(nsACString &aContentDisposition)
{
NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE);
return mChannel->GetContentDisposition(aContentDisposition);
}
NS_IMETHODIMP NS_IMETHODIMP
nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength) nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -344,13 +344,6 @@ nsPartChannel::GetContentDisposition(nsACString &aContentDisposition)
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP
nsPartChannel::SetContentDisposition(const nsACString &aContentDisposition)
{
mContentDisposition = aContentDisposition;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
nsPartChannel::GetPartID(PRUint32 *aPartID) nsPartChannel::GetPartID(PRUint32 *aPartID)
{ {
@ -800,8 +793,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
rv = mPartChannel->SetContentLength(mContentLength); rv = mPartChannel->SetContentLength(mContentLength);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = mPartChannel->SetContentDisposition(mContentDisposition); mPartChannel->SetContentDisposition(mContentDisposition);
if (NS_FAILED(rv)) return rv;
nsLoadFlags loadFlags = 0; nsLoadFlags loadFlags = 0;
mPartChannel->GetLoadFlags(&loadFlags); mPartChannel->GetLoadFlags(&loadFlags);

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

@ -77,6 +77,11 @@ public:
PRUint32 aOffset, PRUint32 aLen); PRUint32 aOffset, PRUint32 aLen);
nsresult SendOnStopRequest(nsISupports* aContext, nsresult aStatus); nsresult SendOnStopRequest(nsISupports* aContext, nsresult aStatus);
void SetContentDisposition(const nsACString& aDisposition)
{
mContentDisposition = aDisposition;
}
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSIREQUEST NS_DECL_NSIREQUEST
NS_DECL_NSICHANNEL NS_DECL_NSICHANNEL

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

@ -36,7 +36,7 @@
* *
* ***** END LICENSE BLOCK ***** */ * ***** END LICENSE BLOCK ***** */
#include "nsIPropertyBag.idl" #include "nsISupports.idl"
interface nsIInputStream; interface nsIInputStream;
interface nsILocalFile; interface nsILocalFile;
@ -391,8 +391,8 @@ interface nsIHttpRequestHandler : nsISupports
/** /**
* A representation of the data included in an HTTP request. * A representation of the data included in an HTTP request.
*/ */
[scriptable, uuid(80cbca71-dc51-4fa0-9010-1cec262dbd4a)] [scriptable, uuid(978cf30e-ad73-42ee-8f22-fe0aaf1bf5d2)]
interface nsIHttpRequest : nsIPropertyBag interface nsIHttpRequest : nsISupports
{ {
/** /**
* The request type for this request (see RFC 2616, section 5.1.1). * The request type for this request (see RFC 2616, section 5.1.1).

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

@ -386,26 +386,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
// future, because the user has specified external handling for the MIME // future, because the user has specified external handling for the MIME
// type. // type.
PRBool forceExternalHandling = PR_FALSE; PRBool forceExternalHandling = PR_FALSE;
nsCAutoString disposition;
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request)); nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
nsCOMPtr<nsIURI> uri; nsCAutoString disposition;
if (httpChannel) rv = aChannel->GetContentDisposition(disposition);
{
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"),
disposition);
httpChannel->GetURI(getter_AddRefs(uri));
}
else
{
nsCOMPtr<nsIMultiPartChannel> multipartChannel(do_QueryInterface(request));
if (multipartChannel)
{
rv = multipartChannel->GetContentDisposition(disposition);
} else {
// Soon-to-be common way to get Disposition: right now only JARChannel
rv = NS_GetContentDisposition(request, disposition);
}
}
LOG((" Disposition header: '%s'", disposition.get())); LOG((" Disposition header: '%s'", disposition.get()));
@ -415,6 +398,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports *
if (NS_SUCCEEDED(rv)) if (NS_SUCCEEDED(rv))
{ {
nsCAutoString fallbackCharset; nsCAutoString fallbackCharset;
nsCOMPtr<nsIURI> uri;
if (httpChannel)
httpChannel->GetURI(getter_AddRefs(uri));
if (uri) if (uri)
uri->GetOriginCharset(fallbackCharset); uri->GetOriginCharset(fallbackCharset);
nsAutoString dispToken; nsAutoString dispToken;

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

@ -69,6 +69,7 @@ ExternalHelperAppParent::ExternalHelperAppParent(
void void
ExternalHelperAppParent::Init(TabParent *parent, ExternalHelperAppParent::Init(TabParent *parent,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const PRBool& aForceSave) const PRBool& aForceSave)
{ {
nsHashPropertyBag::Init(); nsHashPropertyBag::Init();
@ -82,6 +83,7 @@ ExternalHelperAppParent::Init(TabParent *parent,
do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID); do_GetService(NS_EXTERNALHELPERAPPSERVICE_CONTRACTID);
NS_ASSERTION(helperAppService, "No Helper App Service!"); NS_ASSERTION(helperAppService, "No Helper App Service!");
mContentDisposition = aContentDisposition;
helperAppService->DoContent(aMimeContentType, this, ir, helperAppService->DoContent(aMimeContentType, this, ir,
aForceSave, getter_AddRefs(mListener)); aForceSave, getter_AddRefs(mListener));
} }
@ -295,6 +297,13 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP
ExternalHelperAppParent::GetContentDisposition(nsACString& aContentDisposition)
{
aContentDisposition = mContentDisposition;
return NS_OK;
}
NS_IMETHODIMP NS_IMETHODIMP
ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength) ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength)
{ {

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

@ -69,6 +69,7 @@ public:
ExternalHelperAppParent(const IPC::URI& uri, const PRInt64& contentLength); ExternalHelperAppParent(const IPC::URI& uri, const PRInt64& contentLength);
void Init(TabParent *parent, void Init(TabParent *parent,
const nsCString& aMimeContentType, const nsCString& aMimeContentType,
const nsCString& aContentDisposition,
const PRBool& aForceSave); const PRBool& aForceSave);
virtual ~ExternalHelperAppParent(); virtual ~ExternalHelperAppParent();
@ -79,6 +80,7 @@ private:
nsLoadFlags mLoadFlags; nsLoadFlags mLoadFlags;
nsresult mStatus; nsresult mStatus;
PRInt64 mContentLength; PRInt64 mContentLength;
nsCString mContentDisposition;
nsCString mEntityID; nsCString mEntityID;
}; };

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

@ -222,31 +222,6 @@ static nsresult UnescapeFragment(const nsACString& aFragment, nsIURI* aURI,
return rv; return rv;
} }
/** Gets the content-disposition header from a channel, using nsIHttpChannel
* or nsIMultipartChannel if available
* @param aChannel The channel to extract the disposition header from
* @param aDisposition Reference to a string where the header is to be stored
*/
static void ExtractDisposition(nsIChannel* aChannel, nsACString& aDisposition)
{
aDisposition.Truncate();
// First see whether this is an http channel
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel));
if (httpChannel)
{
httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), aDisposition);
}
if (aDisposition.IsEmpty())
{
nsCOMPtr<nsIMultiPartChannel> multipartChannel(do_QueryInterface(aChannel));
if (multipartChannel)
{
multipartChannel->GetContentDisposition(aDisposition);
}
}
}
/** Extracts the filename out of a content-disposition header /** Extracts the filename out of a content-disposition header
* @param aFilename [out] The filename. Can be empty on error. * @param aFilename [out] The filename. Can be empty on error.
* @param aDisposition Value of a Content-Disposition header * @param aDisposition Value of a Content-Disposition header
@ -314,7 +289,7 @@ static PRBool GetFilenameAndExtensionFromChannel(nsIChannel* aChannel,
* permission... otherwise just use our temp file * permission... otherwise just use our temp file
*/ */
nsCAutoString disp; nsCAutoString disp;
ExtractDisposition(aChannel, disp); aChannel->GetContentDisposition(disp);
PRBool handleExternally = PR_FALSE; PRBool handleExternally = PR_FALSE;
nsCOMPtr<nsIURI> uri; nsCOMPtr<nsIURI> uri;
nsresult rv; nsresult rv;
@ -678,8 +653,12 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
PRInt64 contentLength = -1; PRInt64 contentLength = -1;
if (channel) nsCString disp;
if (channel) {
channel->GetContentLength(&contentLength); channel->GetContentLength(&contentLength);
channel->GetContentDisposition(disp);
}
// Now we build a protocol for forwarding our data to the parent. The // Now we build a protocol for forwarding our data to the parent. The
// protocol will act as a listener on the child-side and create a "real" // protocol will act as a listener on the child-side and create a "real"
@ -690,7 +669,7 @@ NS_IMETHODIMP nsExternalHelperAppService::DoContent(const nsACString& aMimeConte
TabChild *child = static_cast<TabChild*>(tabchild.get()); TabChild *child = static_cast<TabChild*>(tabchild.get());
mozilla::dom::PExternalHelperAppChild *pc; mozilla::dom::PExternalHelperAppChild *pc;
pc = child->SendPExternalHelperAppConstructor(IPC::URI(uri), pc = child->SendPExternalHelperAppConstructor(IPC::URI(uri),
nsCString(aMimeContentType), nsCString(aMimeContentType), disp,
aForceSave, contentLength); aForceSave, contentLength);
ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(pc); ExternalHelperAppChild *childListener = static_cast<ExternalHelperAppChild *>(pc);

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

@ -247,6 +247,12 @@ NS_IMETHODIMP nsExtProtocolChannel::SetContentCharset(const nsACString &aContent
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP nsExtProtocolChannel::GetContentDisposition(nsACString &aContentDisposition)
{
aContentDisposition.Truncate();
return NS_OK;
}
NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt64 * aContentLength) NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt64 * aContentLength)
{ {
*aContentLength = -1; *aContentLength = -1;