Uh oh!
There was an error while loading. Please reload this page.
Added RequestContent - #636
Conversation
lovelydinosaur
commented
Dec 13, 2019
NB. The We'll want to think a little about exactly about if/how we want to expose any of this on a |
lovelydinosaur
commented
Dec 13, 2019
Much design credit here is due to @sethmlarson. |
florimondmanca
left a comment
There was a problem hiding this comment.
Really like the separation that this new interface enables too, yes!
Some minor comments/questions, but overall this is great. 😄
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-Authored-By: Florimond Manca <florimond.manca@gmail.com>
lovelydinosaur
commented
Dec 17, 2019
Other thoughts...
None of that is public API tho, so we could treat it incrementally. |
What about
I haven't looked at our multipart implementation, so I can't say yet, but definitely in favor of treating that as a follow-up. :-) |
florimondmanca
left a comment
There was a problem hiding this comment.
This looks good to me as-is, feel free to resolve the question on the content.py module name. :-) Exciting stuff in any case!
lovelydinosaur
commented
Dec 18, 2019
Gotcha. Not 100% sure yet, but I think that's one that is ok to tackle incrementally. 👍 |
Bumps [mkdocs](https://github.com/mkdocs/mkdocs) from 1.4.0 to 1.4.2. - [Release notes](https://github.com/mkdocs/mkdocs/releases) - [Commits](mkdocs/mkdocs@1.4.0...1.4.2) --- updated-dependencies: - dependency-name: mkdocs dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tom Christie <tom@tomchristie.com>
The RequestContent interface
This pull requests adds
RequestContentas the internal interface for all request body construction. The RequestContent interface provides:.get_headers()- Return the headers for the encoding..is_rewindable()- True if the content can be replayed, False otherwise.async def __aiter__() -> bytes- Returns the byte stream for the encoded data.There are a few concrete implementations.
RequestContent- An empty request content.BytesRequestContent- Handles plain bytes and str content.StreamingRequestContent- Handles byte async iterables. Not rewindable.JSONRequestContent- Handles JSON data.URLEncodedRequestContent- Handles URL encoded form data.MultipartEncodedRequestContent- Handles Multipart encoded form data.There is also a top level function for handling returning a
RequestContentinstance, givendata, files, jsonarguments.encode(data, files, json) -> RequestContentMotivation
Short: Generally a much nicer seperation of logic & will allow us to support both sync+async cases on a single
Requestclass.Requestclass itself, and testable in isolation.__iter__on the the interface alongside the existing__aiter__- most encodings will support both. The StreamingRequestContent will end up as two distinct cases sync+async, which will only support one or the other case, and will error if used incorrectly. (Eg. passing an async iterable as adata=argument will raise an error when used with a sync client.)