Bug 1914521 - Make nsPartChannel inherit the content disposition of the multipart response r=necko-reviewers,jesup

Differential Revision: https://phabricator.services.mozilla.com/D223728
This commit is contained in:
Valentin Gosu 2024-10-01 11:09:09 +00:00
parent d3afb44269
commit cedff4e196
2 changed files with 17 additions and 5 deletions

View File

@ -474,6 +474,12 @@ nsMultiMixedConv::OnStartRequest(nsIRequest* request) {
if (NS_SUCCEEDED(rv)) { if (NS_SUCCEEDED(rv)) {
mRootContentSecurityPolicy = csp; mRootContentSecurityPolicy = csp;
} }
nsCString contentDisposition;
rv = httpChannel->GetResponseHeader("content-disposition"_ns,
contentDisposition);
if (NS_SUCCEEDED(rv)) {
mRootContentDisposition = contentDisposition;
}
} else { } else {
// try asking the channel directly // try asking the channel directly
rv = mChannel->GetContentType(contentType); rv = mChannel->GetContentType(contentType);
@ -850,7 +856,11 @@ nsresult nsMultiMixedConv::SendStart() {
rv = mPartChannel->SetContentLength(mContentLength); rv = mPartChannel->SetContentLength(mContentLength);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
mPartChannel->SetContentDisposition(mContentDisposition); if (!mRootContentDisposition.IsEmpty()) {
mPartChannel->SetContentDisposition(mRootContentDisposition);
} else {
mPartChannel->SetContentDisposition(mContentDisposition);
}
// Each part of a multipart/replace response can be used // Each part of a multipart/replace response can be used
// for the top level document. We must inform upper layers // for the top level document. We must inform upper layers

View File

@ -151,15 +151,17 @@ class nsMultiMixedConv : public nsIStreamConverter {
nsCOMPtr<nsIStreamListener> mFinalListener; // this guy gets the converted nsCOMPtr<nsIStreamListener> mFinalListener; // this guy gets the converted
// data via his OnDataAvailable() // data via his OnDataAvailable()
nsCOMPtr<nsIChannel> // The channel as we get it in OnStartRequest call
mChannel; // The channel as we get in in OnStartRequest call nsCOMPtr<nsIChannel> mChannel;
RefPtr<nsPartChannel> mPartChannel; // the channel for the given part we're // the channel for the given part we're
// processing. one channel per part. // processing. one channel per part.
RefPtr<nsPartChannel> mPartChannel;
nsCOMPtr<nsISupports> mContext; nsCOMPtr<nsISupports> mContext;
nsCString mContentType; nsCString mContentType;
nsCString mContentDisposition; nsCString mContentDisposition;
nsCString mContentSecurityPolicy; nsCString mContentSecurityPolicy;
nsCString mRootContentSecurityPolicy; nsCString mRootContentSecurityPolicy;
nsCString mRootContentDisposition;
uint64_t mContentLength{UINT64_MAX}; uint64_t mContentLength{UINT64_MAX};
uint64_t mTotalSent{0}; uint64_t mTotalSent{0};