зеркало из https://github.com/mozilla/pjs.git
Back out Bug 589292.
This commit is contained in:
Родитель
6e68061138
Коммит
363355fc1c
|
@ -6720,11 +6720,14 @@ nsDocument::RetrieveRelevantHeaders(nsIChannel *aChannel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nsCAutoString contentDisp;
|
nsCOMPtr<nsIMultiPartChannel> partChannel = do_QueryInterface(aChannel);
|
||||||
rv = aChannel->GetContentDisposition(contentDisp);
|
if (partChannel) {
|
||||||
if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) {
|
nsCAutoString contentDisp;
|
||||||
SetHeaderData(nsGkAtoms::headerContentDisposition,
|
rv = partChannel->GetContentDisposition(contentDisp);
|
||||||
NS_ConvertASCIItoUTF16(contentDisp));
|
if (NS_SUCCEEDED(rv) && !contentDisp.IsEmpty()) {
|
||||||
|
SetHeaderData(nsGkAtoms::headerContentDisposition,
|
||||||
|
NS_ConvertASCIItoUTF16(contentDisp));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2407,7 +2407,6 @@ 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,13 +264,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1011,12 +1011,6 @@ 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,13 +631,6 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -778,6 +771,7 @@ 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));
|
||||||
|
|
||||||
|
@ -786,7 +780,6 @@ 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;
|
||||||
|
@ -797,6 +790,10 @@ 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) {
|
||||||
|
@ -804,9 +801,11 @@ 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,7 +96,6 @@ 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,13 +407,6 @@ 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,13 +399,6 @@ 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,13 +636,6 @@ 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,13 +693,6 @@ 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;
|
||||||
|
|
|
@ -988,10 +988,11 @@ 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);
|
||||||
|
@ -1031,8 +1032,14 @@ 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;
|
||||||
if (chan) {
|
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aRequest));
|
||||||
chan->GetContentDisposition(disposition);
|
if (httpChannel) {
|
||||||
|
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"));
|
||||||
|
@ -1092,7 +1099,6 @@ 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,6 +50,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
@ -58,8 +65,11 @@
|
||||||
#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(3906f857-3d79-4716-be55-ed2455d666f4)]
|
[scriptable, uuid(e0bb5c49-c54e-4efb-8f0d-6a7edd926fab)]
|
||||||
interface nsIChannel : nsIRequest
|
interface nsIChannel : nsIRequest
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -157,13 +157,6 @@ 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(51698f28-c975-4bce-a951-25130cda0113)]
|
[scriptable, uuid(ba78db7b-b88c-4b76-baf9-3c2296a585ae)]
|
||||||
interface nsIMultiPartChannel : nsISupports
|
interface nsIMultiPartChannel : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -53,6 +53,13 @@ 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,6 +47,7 @@ class nsNetStrings {
|
||||||
public:
|
public:
|
||||||
nsNetStrings();
|
nsNetStrings();
|
||||||
|
|
||||||
|
const nsLiteralString kContentDisposition;
|
||||||
const nsLiteralString kChannelPolicy;
|
const nsLiteralString kChannelPolicy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -238,6 +238,19 @@ 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,13 +503,6 @@ 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,7 +290,6 @@ 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,7 +40,8 @@
|
||||||
NS_HIDDEN_(nsNetStrings*) gNetStrings;
|
NS_HIDDEN_(nsNetStrings*) gNetStrings;
|
||||||
|
|
||||||
nsNetStrings::nsNetStrings()
|
nsNetStrings::nsNetStrings()
|
||||||
: NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
|
: NS_LITERAL_STRING_INIT(kContentDisposition, NS_CHANNEL_PROP_CONTENT_DISPOSITION_STR),
|
||||||
|
NS_LITERAL_STRING_INIT(kChannelPolicy, NS_CHANNEL_PROP_CHANNEL_POLICY_STR)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -358,18 +358,6 @@ 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,7 +129,6 @@ 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,14 +369,6 @@ 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,6 +344,13 @@ 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)
|
||||||
{
|
{
|
||||||
|
@ -793,7 +800,8 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
|
||||||
rv = mPartChannel->SetContentLength(mContentLength);
|
rv = mPartChannel->SetContentLength(mContentLength);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
mPartChannel->SetContentDisposition(mContentDisposition);
|
rv = mPartChannel->SetContentDisposition(mContentDisposition);
|
||||||
|
if (NS_FAILED(rv)) return rv;
|
||||||
|
|
||||||
nsLoadFlags loadFlags = 0;
|
nsLoadFlags loadFlags = 0;
|
||||||
mPartChannel->GetLoadFlags(&loadFlags);
|
mPartChannel->GetLoadFlags(&loadFlags);
|
||||||
|
|
|
@ -77,11 +77,6 @@ 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
|
||||||
|
|
|
@ -386,9 +386,26 @@ 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;
|
||||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
|
|
||||||
nsCAutoString disposition;
|
nsCAutoString disposition;
|
||||||
rv = aChannel->GetContentDisposition(disposition);
|
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(request));
|
||||||
|
nsCOMPtr<nsIURI> uri;
|
||||||
|
if (httpChannel)
|
||||||
|
{
|
||||||
|
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()));
|
||||||
|
|
||||||
|
@ -398,9 +415,6 @@ 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;
|
||||||
|
|
|
@ -295,13 +295,6 @@ ExternalHelperAppParent::SetContentCharset(const nsACString& aContentCharset)
|
||||||
return NS_ERROR_NOT_IMPLEMENTED;
|
return NS_ERROR_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
ExternalHelperAppParent::GetContentDisposition(nsACString& aContentDisposition)
|
|
||||||
{
|
|
||||||
aContentDisposition.Truncate();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength)
|
ExternalHelperAppParent::GetContentLength(PRInt64 *aContentLength)
|
||||||
{
|
{
|
||||||
|
|
|
@ -222,6 +222,31 @@ 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
|
||||||
|
@ -289,7 +314,7 @@ static PRBool GetFilenameAndExtensionFromChannel(nsIChannel* aChannel,
|
||||||
* permission... otherwise just use our temp file
|
* permission... otherwise just use our temp file
|
||||||
*/
|
*/
|
||||||
nsCAutoString disp;
|
nsCAutoString disp;
|
||||||
aChannel->GetContentDisposition(disp);
|
ExtractDisposition(aChannel, disp);
|
||||||
PRBool handleExternally = PR_FALSE;
|
PRBool handleExternally = PR_FALSE;
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
|
@ -247,12 +247,6 @@ 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;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче