mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
browser(firefox): allow to override content-type along with post data (#4416)
This commit is contained in:
parent
eee82a7fca
commit
8488c296f9
@ -1,2 +1,2 @@
|
||||
1205
|
||||
Changed: dgozman@gmail.com Sun Nov 8 07:09:21 PST 2020
|
||||
1206
|
||||
Changed: yurys@chromium.org Thu 12 Nov 2020 10:23:24 AM PST
|
||||
|
||||
@ -238,9 +238,20 @@ class NetworkRequest {
|
||||
const synthesized = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
|
||||
const body = atob(postData);
|
||||
synthesized.setData(body, body.length);
|
||||
|
||||
const overridenHeader = (lowerCaseName, defaultValue) => {
|
||||
if (headers) {
|
||||
for (const header of headers) {
|
||||
if (header.name.toLowerCase() === lowerCaseName) {
|
||||
return header.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
// Clear content-length, so that upload stream resets it.
|
||||
this.httpChannel.setRequestHeader('content-length', '', false /* merge */);
|
||||
this.httpChannel.explicitSetUploadStream(synthesized, 'application/octet-stream', -1, this.httpChannel.requestMethod, false);
|
||||
this.httpChannel.setRequestHeader('content-length', overridenHeader('content-length', ''), false /* merge */);
|
||||
this.httpChannel.explicitSetUploadStream(synthesized, overridenHeader('content-type', 'application/octet-stream'), -1, this.httpChannel.requestMethod, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user