Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add response Truncate limit to truncate large responses #3119

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/run/summary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
var _ = require('lodash'),
sdk = require('postman-collection'),
SerialiseError = require('serialised-error'),
RunSummary;
RunSummary,
_responseTruncateLimit = Infinity;

/**
* Creates and returns a RunSummary instance for the current collection run.
Expand All @@ -14,6 +15,9 @@ RunSummary = function RunSummary (emitter, options) {
// keep a copy of this instance since, we need to refer to this from various events
var summary = this;

// Set responseTruncateLimit
_responseTruncateLimit = _.get(options, 'responseTruncateLimit', _responseTruncateLimit);

// and store the trackers and failures in the summary object itself
_.assign(summary, /** @lends RunSummary.prototype */ {
/**
Expand Down Expand Up @@ -225,10 +229,20 @@ _.assign(RunSummary, {

var execution = cache[o.cursor.ref] = (cache[o.cursor.ref] || {});

// Copy response object
let response = {};

_.assign(response, o.response);

// Truncate large response body
if (_.get(response, 'stream') && response.stream.length > _responseTruncateLimit) {
response.stream = response.stream.slice(0, _responseTruncateLimit);
}

executions.push(_.assignIn(execution, {
cursor: o.cursor,
request: o.request,
response: o.response,
response: response,
id: _.get(o, 'item.id')
}, err && {
requestError: err || undefined
Expand Down
Loading