browser(firefox): preserve content-type from original request if it i… (#16739)
This commit is contained in:
Родитель
ff46d8ce8a
Коммит
a8249163d3
|
@ -1,2 +1,2 @@
|
||||||
1347
|
1348
|
||||||
Changed: aslushnikov@gmail.com Sat Aug 13 14:56:35 MSK 2022
|
Changed: yurys@chromium.org Mon Aug 22 16:59:01 PDT 2022
|
||||||
|
|
|
@ -863,7 +863,7 @@ function setPostData(httpChannel, postData, headers) {
|
||||||
const body = atob(postData);
|
const body = atob(postData);
|
||||||
synthesized.setData(body, body.length);
|
synthesized.setData(body, body.length);
|
||||||
|
|
||||||
const overriddenHeader = (lowerCaseName, defaultValue) => {
|
const overriddenHeader = (lowerCaseName) => {
|
||||||
if (headers) {
|
if (headers) {
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
if (header.name.toLowerCase() === lowerCaseName) {
|
if (header.name.toLowerCase() === lowerCaseName) {
|
||||||
|
@ -871,11 +871,22 @@ function setPostData(httpChannel, postData, headers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return undefined;
|
||||||
}
|
}
|
||||||
// Clear content-length, so that upload stream resets it.
|
// Clear content-length, so that upload stream resets it.
|
||||||
httpChannel.setRequestHeader('content-length', '', false /* merge */);
|
httpChannel.setRequestHeader('content-length', '', false /* merge */);
|
||||||
httpChannel.explicitSetUploadStream(synthesized, overriddenHeader('content-type', 'application/octet-stream'), -1, httpChannel.requestMethod, false);
|
let contentType = overriddenHeader('content-type');
|
||||||
|
if (contentType === undefined) {
|
||||||
|
try {
|
||||||
|
contentType = httpChannel.getRequestHeader('content-type');
|
||||||
|
} catch (e) {
|
||||||
|
if (e.result == Cr.NS_ERROR_NOT_AVAILABLE)
|
||||||
|
contentType = 'application/octet-stream';
|
||||||
|
else
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
httpChannel.explicitSetUploadStream(synthesized, contentType, -1, httpChannel.requestMethod, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertString(s, source, dest) {
|
function convertString(s, source, dest) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
1345
|
1346
|
||||||
Changed: aslushnikov@gmail.com Sat Aug 13 14:45:35 MSK 2022
|
Changed: yurys@chromium.org Mon Aug 22 16:56:24 PDT 2022
|
||||||
|
|
|
@ -863,7 +863,7 @@ function setPostData(httpChannel, postData, headers) {
|
||||||
const body = atob(postData);
|
const body = atob(postData);
|
||||||
synthesized.setData(body, body.length);
|
synthesized.setData(body, body.length);
|
||||||
|
|
||||||
const overriddenHeader = (lowerCaseName, defaultValue) => {
|
const overriddenHeader = (lowerCaseName) => {
|
||||||
if (headers) {
|
if (headers) {
|
||||||
for (const header of headers) {
|
for (const header of headers) {
|
||||||
if (header.name.toLowerCase() === lowerCaseName) {
|
if (header.name.toLowerCase() === lowerCaseName) {
|
||||||
|
@ -871,11 +871,22 @@ function setPostData(httpChannel, postData, headers) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
return undefined;
|
||||||
}
|
}
|
||||||
// Clear content-length, so that upload stream resets it.
|
// Clear content-length, so that upload stream resets it.
|
||||||
httpChannel.setRequestHeader('content-length', '', false /* merge */);
|
httpChannel.setRequestHeader('content-length', '', false /* merge */);
|
||||||
httpChannel.explicitSetUploadStream(synthesized, overriddenHeader('content-type', 'application/octet-stream'), -1, httpChannel.requestMethod, false);
|
let contentType = overriddenHeader('content-type');
|
||||||
|
if (contentType === undefined) {
|
||||||
|
try {
|
||||||
|
contentType = httpChannel.getRequestHeader('content-type');
|
||||||
|
} catch (e) {
|
||||||
|
if (e.result == Cr.NS_ERROR_NOT_AVAILABLE)
|
||||||
|
contentType = 'application/octet-stream';
|
||||||
|
else
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
httpChannel.explicitSetUploadStream(synthesized, contentType, -1, httpChannel.requestMethod, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertString(s, source, dest) {
|
function convertString(s, source, dest) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче