Skip to content

Commit 5c78db8

Browse files
author
dhwaneetbhatt
committed
Add safety checks for request protocolProfileBehavior
1 parent d0156cf commit 5c78db8

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

codegens/curl/lib/util.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,18 @@ var self = module.exports = {
292292
* @returns {Boolean}
293293
*/
294294
shouldAddHttpMethod: function (request, options) {
295-
const followRedirect = _.get(request, 'protocolProfileBehavior.followRedirects', options.followRedirect),
296-
followOriginalHttpMethod =
297-
_.get(request, 'protocolProfileBehavior.followOriginalHttpMethod', options.followOriginalHttpMethod),
298-
disableBodyPruning = _.get(request, 'protocolProfileBehavior.disableBodyPruning', true),
295+
let followRedirect = options.followRedirect,
296+
followOriginalHttpMethod = options.followOriginalHttpMethod,
297+
disableBodyPruning = true,
299298
isBodyEmpty = self.isBodyEmpty(request.body);
300299

300+
if (_.has(request, 'protocolProfileBehavior') && request.protocolProfileBehavior !== null) {
301+
followRedirect = _.get(request, 'protocolProfileBehavior.followRedirects', followRedirect);
302+
followOriginalHttpMethod =
303+
_.get(request, 'protocolProfileBehavior.followOriginalHttpMethod', followOriginalHttpMethod);
304+
disableBodyPruning = _.get(request, 'protocolProfileBehavior.disableBodyPruning', true);
305+
}
306+
301307
if (followRedirect && followOriginalHttpMethod) {
302308
return true;
303309
}

0 commit comments

Comments
 (0)