🎨
This commit is contained in:
parent
5f596b22c7
commit
50019f39e9
2 changed files with 11 additions and 12 deletions
|
@ -120,14 +120,13 @@ const createGuest = function (embedder, url, frameName, options, postData) {
|
||||||
// The above code would not work if a navigation to "about:blank" is done
|
// The above code would not work if a navigation to "about:blank" is done
|
||||||
// here, since the window would be cleared of all changes in the next tick.
|
// here, since the window would be cleared of all changes in the next tick.
|
||||||
const loadOptions = {}
|
const loadOptions = {}
|
||||||
if (postData) {
|
if (postData != null) {
|
||||||
loadOptions.postData = postData
|
loadOptions.postData = postData
|
||||||
loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded'
|
loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded'
|
||||||
if (postData.length) {
|
if (postData.length > 0) {
|
||||||
const postDataFront = postData[0].bytes.toString()
|
const postDataFront = postData[0].bytes.toString()
|
||||||
const regex = new RegExp(/^--.*[^-\r\n]/)
|
const boundary = /^--.*[^-\r\n]/.exec(postDataFront)
|
||||||
const boundary = regex.exec(postDataFront)
|
if (boundary != null) {
|
||||||
if (boundary) {
|
|
||||||
loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}`
|
loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,15 +29,15 @@ describe('browser-window module', function () {
|
||||||
const fileStats = fs.statSync(filePath)
|
const fileStats = fs.statSync(filePath)
|
||||||
postData = [
|
postData = [
|
||||||
{
|
{
|
||||||
'type': 'rawData',
|
type: 'rawData',
|
||||||
'bytes': new Buffer('username=test&file=')
|
bytes: new Buffer('username=test&file=')
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'type': 'file',
|
type: 'file',
|
||||||
'filePath': filePath,
|
filePath: filePath,
|
||||||
'offset': 0,
|
offset: 0,
|
||||||
'length': fileStats.size,
|
length: fileStats.size,
|
||||||
'modificationTime': fileStats.mtime.getTime() / 1000
|
modificationTime: fileStats.mtime.getTime() / 1000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
server = http.createServer(function (req, res) {
|
server = http.createServer(function (req, res) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue