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

hide binary response data in debug #1884 #3985

Merged
merged 2 commits into from Feb 3, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Codeception/Module/REST.php
Expand Up @@ -498,7 +498,13 @@ protected function execute($method, $url, $parameters = [], $files = [])
$this->debugSection("Request", "$method $url " . $requestData);
$this->response = (string)$this->connectionModule->_request($method, $url, [], $files, [], $parameters);
}
$this->debugSection("Response", $this->response);
$response = $this->response;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you name as printedResponse so it would be obvious that this is can't be used as real response

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense.

I'll also rework it to move the formatting out to a couple of methods, so that the code is not repeated.

if (!ctype_print($response) && false === mb_detect_encoding($response, mb_detect_order(), true)) {
// if the response has non-printable bytes and it is not a valid unicode string, reformat the
// display string to signify the presence of a binary response
$response = '[binary-data length:' . strlen($response) . ' md5:' . md5($response) . ']';
}
$this->debugSection("Response", $response);
}

protected function encodeApplicationJson($method, $parameters)
Expand Down