Reset the RawHttpResponse.Body buffer so that it can be re-read by the caller #14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Reset the RawHttpResponse.Body buffer so that it can be re-read by the caller.
Description
When the consumer of the
fullcontact-go
client tries to read theRawHttpResponse.Body
, it comes back empty. This happens because all of thesetXXXXResponse
helper functions read the body (which is anio.ReadCloser
type) in order to populate theAPIResponse
fields. The problem is that after you read from ioutil.ReadAll(), the content is gone - you can’t read from it a second time, and there's nothing the consumer can do to get this data back.In order to remedy this, we changed the code to "reset" the field after it is read inside the helper functions. This allows us as the consumer to read the body ourselves.