specify content type depending on post data

This commit is contained in:
deepak1556 2016-11-10 19:25:34 +05:30 committed by Kevin Sawicki
parent cbb68f6980
commit 5f596b22c7

View file

@ -122,6 +122,15 @@ const createGuest = function (embedder, url, frameName, options, postData) {
const loadOptions = {}
if (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)
}