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

Add NewRawRequest #170

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Add NewRawRequest #170

merged 2 commits into from
Oct 14, 2024

Conversation

milesbxf
Copy link
Contributor

@milesbxf milesbxf commented Feb 9, 2024

One common pitfall of using typhon.NewRequest for standard HTTP usage is that it's easy to try and use it like a regular http.NewRequest and pass in a raw body (e.g. a []byte), expecting that to work the same - but then Typhon encodes the body as JSON. Now of course you could pass in an io.ReadCloser/io.Reader to avoid this, but you'd only know this from digging deep into the Typhon code, not from the docstrings!

This adds NewRawRequest as a bit of sugar to guide someone into the expected behaviour.

milesbxf and others added 2 commits February 9, 2024 09:29
One common pitfall of using typhon.NewRequest for standard HTTP usage is that it's easy to try and use it like a regular http.NewRequest and pass in a raw body, expecting that to work - but then Typhon encodes the body as JSON. Now of course you could pass in an io.ReadCloser/io.Reader to avoid this, but you'd only know this from digging deep into the Typhon code, not from the docstrings!
@milesbxf milesbxf merged commit 9796f78 into master Oct 14, 2024
2 checks passed
@milesbxf milesbxf deleted the typhon-raw-request branch October 17, 2024 08:49
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