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

Reset the RawHttpResponse.Body buffer so that it can be re-read by the caller #14

Merged
merged 1 commit into from
Feb 9, 2024

Conversation

kishiyama
Copy link
Contributor

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 the RawHttpResponse.Body, it comes back empty. This happens because all of the setXXXXResponse helper functions read the body (which is an io.ReadCloser type) in order to populate the APIResponse 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.

Copy link
Member

@McManCSU McManCSU left a comment

Choose a reason for hiding this comment

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

Thanks @kishiyama

@McManCSU McManCSU merged commit c5780be into fullcontact:master Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants