diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 25d32d97b27..18230c826dd 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -6694,14 +6694,11 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel) } } } else { - nsCOMPtr partChannel = do_QueryInterface(aChannel); - if (partChannel) { - nsCAutoString contentDisp; - rv = partChannel->GetContentDisposition(contentDisp); - if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) { - SetHeaderData(nsGkAtoms::headerContentDisposition, - NS_ConvertASCIItoUTF16(contentDisp)); - } + nsCAutoString contentDisp; + rv = aChannel->GetContentDisposition(contentDisp); + if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) { + SetHeaderData(nsGkAtoms::headerContentDisposition, + NS_ConvertASCIItoUTF16(contentDisp)); } } } diff --git a/content/base/src/nsWebSocket.cpp b/content/base/src/nsWebSocket.cpp index 17f280b630f..c66d447afde 100644 --- a/content/base/src/nsWebSocket.cpp +++ b/content/base/src/nsWebSocket.cpp @@ -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(GetContentCharset, 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(SetContentLength, PRInt64 value) NOT_IMPLEMENTED_IF_FUNC_1(Open, nsIInputStream **_retval) diff --git a/content/html/document/src/nsWyciwygChannel.cpp b/content/html/document/src/nsWyciwygChannel.cpp index ef72322399c..0c2e3b055a2 100644 --- a/content/html/document/src/nsWyciwygChannel.cpp +++ b/content/html/document/src/nsWyciwygChannel.cpp @@ -264,6 +264,13 @@ nsWyciwygChannel::SetContentCharset(const nsACString &aContentCharset) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +nsWyciwygChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsWyciwygChannel::GetContentLength(PRInt64 *aContentLength) { diff --git a/dom/src/jsurl/nsJSProtocolHandler.cpp b/dom/src/jsurl/nsJSProtocolHandler.cpp index 9eff31d3d7b..a5ffbf68431 100644 --- a/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -1011,6 +1011,12 @@ nsJSChannel::SetContentCharset(const nsACString &aContentCharset) return mStreamChannel->SetContentCharset(aContentCharset); } +NS_IMETHODIMP +nsJSChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + return mStreamChannel->GetContentDisposition(aContentDisposition); +} + NS_IMETHODIMP nsJSChannel::GetContentLength(PRInt64 *aContentLength) { diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index edd7a6e65d6..909a5f6af72 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -631,6 +631,13 @@ nsJARChannel::SetContentCharset(const nsACString &aContentCharset) return NS_OK; } +NS_IMETHODIMP +nsJARChannel::GetContentDisposition(nsACString &result) +{ + result = mContentDisposition; + return NS_OK; +} + NS_IMETHODIMP nsJARChannel::GetContentLength(PRInt64 *result) { @@ -771,7 +778,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader, } if (NS_SUCCEEDED(status) && channel) { - nsCAutoString header; // Grab the security info from our base channel 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 // send us a JAR file. Check the server-supplied content type for // a JAR type. + nsCAutoString header; httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("Content-Type"), header); nsCAutoString contentType; @@ -790,10 +797,6 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader, mIsUnsafe = !(contentType.Equals(channelContentType) && (contentType.EqualsLiteral("application/java-archive") || 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 { nsCOMPtr innerJARChannel(do_QueryInterface(channel)); if (innerJARChannel) { @@ -801,11 +804,9 @@ nsJARChannel::OnDownloadComplete(nsIDownloader *downloader, innerJARChannel->GetIsUnsafe(&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) { diff --git a/modules/libjar/nsJARChannel.h b/modules/libjar/nsJARChannel.h index 5556e7067a8..52e5b88feb3 100644 --- a/modules/libjar/nsJARChannel.h +++ b/modules/libjar/nsJARChannel.h @@ -96,6 +96,7 @@ private: nsCOMPtr mListenerContext; nsCString mContentType; nsCString mContentCharset; + nsCString mContentDisposition; PRInt64 mContentLength; PRUint32 mLoadFlags; nsresult mStatus; diff --git a/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp index 3e33e4a2bac..e6dc3b72291 100644 --- a/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/beos/nsIconChannel.cpp @@ -407,6 +407,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsIconChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) { *aContentLength = mContentLength; diff --git a/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm b/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm index 31fe19ff41f..cc27ac4c97c 100644 --- a/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm +++ b/modules/libpr0n/decoders/icon/mac/nsIconChannelCocoa.mm @@ -399,6 +399,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsIconChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) { *aContentLength = mContentLength; diff --git a/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp index a0d7ed3eef3..8d3f4b51edc 100644 --- a/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/os2/nsIconChannel.cpp @@ -636,6 +636,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsIconChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) { *aContentLength = mContentLength; diff --git a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index e306da41de3..61ae9b8204c 100644 --- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -693,6 +693,13 @@ nsIconChannel::SetContentCharset(const nsACString &aContentCharset) return NS_ERROR_FAILURE; } +NS_IMETHODIMP +nsIconChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsIconChannel::GetContentLength(PRInt64 *aContentLength) { *aContentLength = mContentLength; diff --git a/modules/libpr0n/src/imgRequest.cpp b/modules/libpr0n/src/imgRequest.cpp index 6a86499fd07..b79ef268dd0 100644 --- a/modules/libpr0n/src/imgRequest.cpp +++ b/modules/libpr0n/src/imgRequest.cpp @@ -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 */ #endif + nsCOMPtr chan(do_QueryInterface(aRequest)); if (mContentType.IsEmpty()) { LOG_SCOPE(gImgLog, "imgRequest::OnDataAvailable |sniffing of mimetype failed|"); - nsCOMPtr chan(do_QueryInterface(aRequest)); - rv = NS_ERROR_FAILURE; if (chan) { rv = chan->GetContentType(mContentType); @@ -1017,14 +1016,8 @@ NS_IMETHODIMP imgRequest::OnDataAvailable(nsIRequest *aRequest, nsISupports *ctx /* set our content disposition as a property */ nsCAutoString disposition; - nsCOMPtr httpChannel(do_QueryInterface(aRequest)); - if (httpChannel) { - httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), disposition); - } else { - nsCOMPtr multiPartChannel(do_QueryInterface(aRequest)); - if (multiPartChannel) { - multiPartChannel->GetContentDisposition(disposition); - } + if (chan) { + chan->GetContentDisposition(disposition); } if (!disposition.IsEmpty()) { nsCOMPtr 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) { /* Use content-length as a size hint for http channels. */ + nsCOMPtr httpChannel(do_QueryInterface(aRequest)); if (httpChannel) { PRInt64 contentLength; rv = httpChannel->GetContentLength(&contentLength); diff --git a/netwerk/base/public/nsChannelProperties.h b/netwerk/base/public/nsChannelProperties.h index 323f8feefac..c3ca6c27b0b 100644 --- a/netwerk/base/public/nsChannelProperties.h +++ b/netwerk/base/public/nsChannelProperties.h @@ -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 * redirects. Contains security contextual information about the load. @@ -65,11 +58,8 @@ #define NS_CHANNEL_PROP_CHANNEL_POLICY_STR "channel-policy" #ifdef IMPL_NS_NET -#define NS_CHANNEL_PROP_CONTENT_DISPOSITION gNetStrings->kContentDisposition #define NS_CHANNEL_PROP_CHANNEL_POLICY gNetStrings->kChannelPolicy #else -#define NS_CHANNEL_PROP_CONTENT_DISPOSITION \ - NS_LITERAL_STRING(NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR) #define NS_CHANNEL_PROP_CHANNEL_POLICY \ NS_LITERAL_STRING(NS_CHANNEL_PROP_CHANNEL_POLICY_STR) #endif diff --git a/netwerk/base/public/nsIChannel.idl b/netwerk/base/public/nsIChannel.idl index 32f21d39122..9d6ab84a416 100644 --- a/netwerk/base/public/nsIChannel.idl +++ b/netwerk/base/public/nsIChannel.idl @@ -56,7 +56,7 @@ interface nsIStreamListener; * * 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 { /** @@ -157,6 +157,13 @@ interface nsIChannel : nsIRequest */ 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. * diff --git a/netwerk/base/public/nsIMultiPartChannel.idl b/netwerk/base/public/nsIMultiPartChannel.idl index 8da5cdf950a..5103f94e10a 100644 --- a/netwerk/base/public/nsIMultiPartChannel.idl +++ b/netwerk/base/public/nsIMultiPartChannel.idl @@ -45,7 +45,7 @@ interface nsIChannel; * associated with a MultiPartChannel. */ -[scriptable, uuid(ba78db7b-b88c-4b76-baf9-3c2296a585ae)] +[scriptable, uuid(51698f28-c975-4bce-a951-25130cda0113)] interface nsIMultiPartChannel : nsISupports { /** @@ -53,13 +53,6 @@ interface nsIMultiPartChannel : nsISupports */ 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 * the same multipart document. diff --git a/netwerk/base/public/nsNetStrings.h b/netwerk/base/public/nsNetStrings.h index 3dbc7533b8e..06e8f196a5d 100644 --- a/netwerk/base/public/nsNetStrings.h +++ b/netwerk/base/public/nsNetStrings.h @@ -47,7 +47,6 @@ class nsNetStrings { public: nsNetStrings(); - const nsLiteralString kContentDisposition; const nsLiteralString kChannelPolicy; }; diff --git a/netwerk/base/public/nsNetUtil.h b/netwerk/base/public/nsNetUtil.h index 686fccc8335..7a4d0778f4f 100644 --- a/netwerk/base/public/nsNetUtil.h +++ b/netwerk/base/public/nsNetUtil.h @@ -238,19 +238,6 @@ NS_NewChannel(nsIChannel **result, 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 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 // 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 diff --git a/netwerk/base/src/nsBaseChannel.cpp b/netwerk/base/src/nsBaseChannel.cpp index effb70b222a..67d0fb058b2 100644 --- a/netwerk/base/src/nsBaseChannel.cpp +++ b/netwerk/base/src/nsBaseChannel.cpp @@ -503,6 +503,13 @@ nsBaseChannel::SetContentCharset(const nsACString &aContentCharset) return NS_OK; } +NS_IMETHODIMP +nsBaseChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition = mContentDisposition; + return NS_OK; +} + NS_IMETHODIMP nsBaseChannel::GetContentLength(PRInt64 *aContentLength) { diff --git a/netwerk/base/src/nsBaseChannel.h b/netwerk/base/src/nsBaseChannel.h index 1656d1df531..62bc47f22b8 100644 --- a/netwerk/base/src/nsBaseChannel.h +++ b/netwerk/base/src/nsBaseChannel.h @@ -290,6 +290,7 @@ private: nsCOMPtr mRedirectChannel; nsCString mContentType; nsCString mContentCharset; + nsCString mContentDisposition; PRInt64 mContentLength; PRUint32 mLoadFlags; nsresult mStatus; diff --git a/netwerk/base/src/nsNetStrings.cpp b/netwerk/base/src/nsNetStrings.cpp index 69dd8e3a0d0..47111f54ce1 100644 --- a/netwerk/base/src/nsNetStrings.cpp +++ b/netwerk/base/src/nsNetStrings.cpp @@ -40,8 +40,7 @@ NS_HIDDEN_(nsNetStrings*) gNetStrings; 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) {} diff --git a/netwerk/protocol/http/HttpBaseChannel.cpp b/netwerk/protocol/http/HttpBaseChannel.cpp index 34f5936b9e9..b59bd3e3a0f 100644 --- a/netwerk/protocol/http/HttpBaseChannel.cpp +++ b/netwerk/protocol/http/HttpBaseChannel.cpp @@ -358,6 +358,18 @@ HttpBaseChannel::SetContentCharset(const nsACString& aContentCharset) 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 HttpBaseChannel::GetContentLength(PRInt64 *aContentLength) { diff --git a/netwerk/protocol/http/HttpBaseChannel.h b/netwerk/protocol/http/HttpBaseChannel.h index 4d35b14484c..eb7e148082b 100644 --- a/netwerk/protocol/http/HttpBaseChannel.h +++ b/netwerk/protocol/http/HttpBaseChannel.h @@ -129,6 +129,7 @@ public: NS_IMETHOD SetContentType(const nsACString& aContentType); NS_IMETHOD GetContentCharset(nsACString& aContentCharset); NS_IMETHOD SetContentCharset(const nsACString& aContentCharset); + NS_IMETHOD GetContentDisposition(nsACString& aContentDisposition); NS_IMETHOD GetContentLength(PRInt64 *aContentLength); NS_IMETHOD SetContentLength(PRInt64 aContentLength); NS_IMETHOD Open(nsIInputStream **aResult); diff --git a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp index 58ea5be16d2..61c0cc2ab5d 100644 --- a/netwerk/protocol/viewsource/nsViewSourceChannel.cpp +++ b/netwerk/protocol/viewsource/nsViewSourceChannel.cpp @@ -369,6 +369,14 @@ nsViewSourceChannel::SetContentCharset(const nsACString &aContentCharset) return mChannel->SetContentCharset(aContentCharset); } +NS_IMETHODIMP +nsViewSourceChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + NS_ENSURE_TRUE(mChannel, NS_ERROR_FAILURE); + + return mChannel->GetContentDisposition(aContentDisposition); +} + NS_IMETHODIMP nsViewSourceChannel::GetContentLength(PRInt64 *aContentLength) { diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index 7d8219f9eee..133c63acc28 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -344,13 +344,6 @@ nsPartChannel::GetContentDisposition(nsACString &aContentDisposition) return NS_OK; } -NS_IMETHODIMP -nsPartChannel::SetContentDisposition(const nsACString &aContentDisposition) -{ - mContentDisposition = aContentDisposition; - return NS_OK; -} - NS_IMETHODIMP nsPartChannel::GetPartID(PRUint32 *aPartID) { @@ -800,8 +793,7 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) { rv = mPartChannel->SetContentLength(mContentLength); if (NS_FAILED(rv)) return rv; - rv = mPartChannel->SetContentDisposition(mContentDisposition); - if (NS_FAILED(rv)) return rv; + mPartChannel->SetContentDisposition(mContentDisposition); nsLoadFlags loadFlags = 0; mPartChannel->GetLoadFlags(&loadFlags); diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index ac919a5b711..b2e29e2eb3d 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -77,6 +77,11 @@ public: PRUint32 aOffset, PRUint32 aLen); nsresult SendOnStopRequest(nsISupports* aContext, nsresult aStatus); + void SetContentDisposition(const nsACString& aDisposition) + { + mContentDisposition = aDisposition; + } + NS_DECL_ISUPPORTS NS_DECL_NSIREQUEST NS_DECL_NSICHANNEL diff --git a/uriloader/base/nsURILoader.cpp b/uriloader/base/nsURILoader.cpp index ccb7ff3684a..3047159a899 100644 --- a/uriloader/base/nsURILoader.cpp +++ b/uriloader/base/nsURILoader.cpp @@ -386,26 +386,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * // future, because the user has specified external handling for the MIME // type. PRBool forceExternalHandling = PR_FALSE; - nsCAutoString disposition; nsCOMPtr httpChannel(do_QueryInterface(request)); - nsCOMPtr uri; - if (httpChannel) - { - rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), - disposition); - httpChannel->GetURI(getter_AddRefs(uri)); - } - else - { - nsCOMPtr 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); - } - } + nsCAutoString disposition; + rv = aChannel->GetContentDisposition(disposition); LOG((" Disposition header: '%s'", disposition.get())); @@ -415,6 +398,9 @@ nsresult nsDocumentOpenInfo::DispatchContent(nsIRequest *request, nsISupports * if (NS_SUCCEEDED(rv)) { nsCAutoString fallbackCharset; + nsCOMPtr uri; + if (httpChannel) + httpChannel->GetURI(getter_AddRefs(uri)); if (uri) uri->GetOriginCharset(fallbackCharset); nsAutoString dispToken; diff --git a/uriloader/exthandler/ExternalHelperAppParent.cpp b/uriloader/exthandler/ExternalHelperAppParent.cpp index 670cdc9e950..80bd97a2bc6 100644 --- a/uriloader/exthandler/ExternalHelperAppParent.cpp +++ b/uriloader/exthandler/ExternalHelperAppParent.cpp @@ -295,6 +295,13 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset) return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP +ExternalHelperAppParent::GetContentDisposition(nsACString& aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength) { diff --git a/uriloader/exthandler/nsExternalHelperAppService.cpp b/uriloader/exthandler/nsExternalHelperAppService.cpp index 14fb02d4cce..402797cb3e9 100644 --- a/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -222,31 +222,6 @@ static nsresult UnescapeFragment(const nsACString& aFragment, nsIURI* aURI, 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 httpChannel(do_QueryInterface(aChannel)); - if (httpChannel) - { - httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"), aDisposition); - } - if (aDisposition.IsEmpty()) - { - nsCOMPtr multipartChannel(do_QueryInterface(aChannel)); - if (multipartChannel) - { - multipartChannel->GetContentDisposition(aDisposition); - } - } - -} - /** Extracts the filename out of a content-disposition header * @param aFilename [out] The filename. Can be empty on error. * @param aDisposition Value of a Content-Disposition header @@ -314,7 +289,7 @@ static PRBool GetFilenameAndExtensionFromChannel(nsIChannel* aChannel, * permission... otherwise just use our temp file */ nsCAutoString disp; - ExtractDisposition(aChannel, disp); + aChannel->GetContentDisposition(disp); PRBool handleExternally = PR_FALSE; nsCOMPtr uri; nsresult rv; diff --git a/uriloader/exthandler/nsExternalProtocolHandler.cpp b/uriloader/exthandler/nsExternalProtocolHandler.cpp index efed358f361..e801b4081dd 100644 --- a/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -247,6 +247,12 @@ NS_IMETHODIMP nsExtProtocolChannel::SetContentCharset(const nsACString &aContent return NS_ERROR_NOT_IMPLEMENTED; } +NS_IMETHODIMP nsExtProtocolChannel::GetContentDisposition(nsACString &aContentDisposition) +{ + aContentDisposition.Truncate(); + return NS_OK; +} + NS_IMETHODIMP nsExtProtocolChannel::GetContentLength(PRInt64 * aContentLength) { *aContentLength = -1;