specify content type depending on post data
This commit is contained in:
parent
cbb68f6980
commit
5f596b22c7
1 changed files with 9 additions and 0 deletions
|
@ -122,6 +122,15 @@ const createGuest = function (embedder, url, frameName, options, postData) {
|
||||||
const loadOptions = {}
|
const loadOptions = {}
|
||||||
if (postData) {
|
if (postData) {
|
||||||
loadOptions.postData = postData
|
loadOptions.postData = postData
|
||||||
|
loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded'
|
||||||
|
if (postData.length) {
|
||||||
|
const postDataFront = postData[0].bytes.toString()
|
||||||
|
const regex = new RegExp(/^--.*[^-\r\n]/)
|
||||||
|
const boundary = regex.exec(postDataFront)
|
||||||
|
if (boundary) {
|
||||||
|
loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}`
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
guest.loadURL(url, loadOptions)
|
guest.loadURL(url, loadOptions)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue