Skip to content

Commit 6f45157

Browse files
authored
fix: correct deconding of http response (#273)
1 parent 11aa362 commit 6f45157

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app/scripts/modules/utils/multipartmixed2har.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,13 @@ const deMultipart = (content, req, res) => {
186186
* @param {Object} header
187187
*/
188188
let resContentType = res.headers.find(header => header.name.toLowerCase() === 'content-type').value;
189-
let raw = atob(content);
190189
let reqBoundary = '--' + req.postData.mimeType.split('boundary=')[1];
191190
let resBoundary = '--' + resContentType.split('boundary=')[1];
192191
// jscs:disable
193192
let requestsRaw = req.postData.text.split(reqBoundary)
194193
.filter(line => !line.startsWith('--') && line !== '')
195194
.filter(removeEmptyLinesFilter);
196-
let responseRaw = raw.split(resBoundary)
195+
let responseRaw = content.split(resBoundary)
197196
.filter(line => !line.startsWith('--') && line !== '')
198197
.filter(removeEmptyLinesFilter);
199198
// jscs:enable
@@ -218,7 +217,10 @@ const getContent = entry =>
218217
* Gets content of an entry.
219218
* @param {Object} content
220219
*/
221-
entry.getContent(content => resolve(content));
220+
entry.getContent((content, encoding) => {
221+
const decodedContent = (encoding === 'base64') ? atob(content) : content;
222+
resolve(decodedContent);
223+
});
222224
}));
223225

224226
exports.getContent = getContent;

0 commit comments

Comments
 (0)