Skip to content

Commit

Permalink
fix: correct deconding of http response (#273)
Browse files Browse the repository at this point in the history
  • Loading branch information
kineticjs authored Oct 25, 2024
1 parent 11aa362 commit 6f45157
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/scripts/modules/utils/multipartmixed2har.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,13 @@ const deMultipart = (content, req, res) => {
* @param {Object} header
*/
let resContentType = res.headers.find(header => header.name.toLowerCase() === 'content-type').value;
let raw = atob(content);
let reqBoundary = '--' + req.postData.mimeType.split('boundary=')[1];
let resBoundary = '--' + resContentType.split('boundary=')[1];
// jscs:disable
let requestsRaw = req.postData.text.split(reqBoundary)
.filter(line => !line.startsWith('--') && line !== '')
.filter(removeEmptyLinesFilter);
let responseRaw = raw.split(resBoundary)
let responseRaw = content.split(resBoundary)
.filter(line => !line.startsWith('--') && line !== '')
.filter(removeEmptyLinesFilter);
// jscs:enable
Expand All @@ -218,7 +217,10 @@ const getContent = entry =>
* Gets content of an entry.
* @param {Object} content
*/
entry.getContent(content => resolve(content));
entry.getContent((content, encoding) => {
const decodedContent = (encoding === 'base64') ? atob(content) : content;
resolve(decodedContent);
});
}));

exports.getContent = getContent;
Expand Down

0 comments on commit 6f45157

Please sign in to comment.