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

fix(cohttp): ensure response body is always consumed #34

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

mattjbray
Copy link
Member

Try to make it obvious that the body is consumed using Util.consume_body or Util.drain_body right next to the request call site.

Try to make it obvious that the body is consumed using
`Util.consume_body` or `Util.drain_body` right next to the request call
site.
Cohttp_lwt_unix.Client.get uri ~headers:metadata_headers
>>= Util.drain_body
Copy link
Member Author

Choose a reason for hiding this comment

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

This was previously being leaked.

@@ -230,22 +233,20 @@ module External_account_credentials = struct
|> to_string

let subject_token_of_response (t : t)
((resp, body) : Cohttp.Response.t * Cohttp_lwt.Body.t) :
((resp, body_str) : Cohttp.Response.t * string) :
Copy link
Member Author

Choose a reason for hiding this comment

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

Helper functions now take a string instead of the Cohttp_lwt.Body.t, to encourange consuming the body at the request call site.

@mattjbray mattjbray merged commit 5abc06a into master Aug 30, 2024
4 checks passed
@mattjbray mattjbray deleted the matt/consume-body branch August 30, 2024 11:07
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