Issue #2648 - Inherit the content disposition of the multipart response

This commit is contained in:
Moonchild 2024-10-30 09:50:08 +01:00 • committed by roytam1
commit 5c0c0c02d9
2 changed files with 13 additions and 1 deletions

View file

@ -722,6 +722,12 @@ nsMultiMixedConv::OnStartRequest(nsIRequest *request, nsISupports *ctxt) {
if (NS_SUCCEEDED(rv)) {
mRootContentSecurityPolicy = csp;
}
nsCString contentDisposition;
rv = httpChannel->GetResponseHeader(NS_LITERAL_CSTRING("content-disposition"),
contentDisposition);
if (NS_SUCCEEDED(rv)) {
mRootContentDisposition = contentDisposition;
}
} else {
// try asking the channel directly
rv = channel->GetContentType(delimiter);
@ -882,7 +888,12 @@ nsMultiMixedConv::SendStart(nsIChannel *aChannel) {
rv = mPartChannel->SetContentLength(mContentLength);
if (NS_FAILED(rv)) return rv;
// Adopt content-disposition from the root doc, if present.
if (!mRootContentDisposition.IsEmpty()) {
mPartChannel->SetContentDisposition(mRootContentDisposition);
} else {
mPartChannel->SetContentDisposition(mContentDisposition);
}
nsLoadFlags loadFlags = 0;
mPartChannel->GetLoadFlags(&loadFlags);

View file

@ -158,6 +158,7 @@ protected:
nsCString mContentDisposition;
nsCString mContentSecurityPolicy;
nsCString mRootContentSecurityPolicy;
nsCString mRootContentDisposition;
uint64_t mContentLength;
char *mBuffer;