From: deepak1556 Date: Thu, 10 Nov 2016 13:55:34 +0000 (+0530) Subject: specify content type depending on post data X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5f596b22c7da4c95a85be9e230e3a9d0a448e648;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git specify content type depending on post data --- diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 0bb7970..3240161 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -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) }