-
Notifications
You must be signed in to change notification settings - Fork 352
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
fix(adapter-node-http): Improve binary response body handling #329
Conversation
|
||
server.get(url).passthrough(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We weren't able to catch this issue since we were doing a passthrough which still went through the adapter.
@@ -37,6 +37,10 @@ export default class Response { | |||
|
|||
if (response.body && typeof response.body === 'string') { | |||
this.content.text = response.body; | |||
|
|||
if (response.isBinary) { | |||
this.content._isBinary = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_isBinary
is only going to the written to the har content if the content is binary. I didnt think it was necessary to always include it. @jasonmit thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fair but some what on topic - does this constitute a breaking change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is backwards compatible but does require to re-record to resolve the issue.
Description
The core issue was in
getChunksFromBody
where we pass it the recorded body and response headers. Since the body is a string, it can't really know if the original buffer was binary or not. To get around that, we now store whether the response content is binary or not in the HAR file and expose it via the response class.Motivation and Context
Resolves #327.
Types of Changes
Checklist