feat(example): add client 100 Continue with fixed body POST example #3910
+255
−0
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.
Notes
This commit adds a new client example demonstrating HTTP 100 Continue functionality.
Background
Hyper Client originally didn't have support for the HTTP 100 Continue functionality.
As per RFC 7231, the client is expected to wait for the 100 Continue from the server after sending only the header parts.
Following the discussion in #3833, the
on_informational
hook has been officially exposed, allowing the Hyper client to support 100 Continue functionality based on its usage.This example aims to help new developers easily implement 100 Continue functionality with the Hyper client. The included server is intended only to provide a complete, working scenario.
Tests
Since it is not easy to test 100 Continue with public APIs, this was tested in the following scenario using the included mock server.
Run mock TCP server:
cargo run --example client_100_continue --features="full" -- --server 8080
Run client:
cargo run --example client_100_continue --features="full" -- http://127.0.0.1:8080