refactor: Improve client API design and documentation #387
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.
This pull request includes significant changes to the
rquest
library, focusing on renaming example files, updating configurations, and introducing a newHttpContext
structure. The most important changes include renaming and updating examples, refactoring theClientBuilder
to useHttpContext
, and removing outdated settings.Renaming and Updating Examples:
Cargo.toml
: Renamed example files to better reflect their purpose and updated paths accordingly. ([Cargo.tomlL267-R272](https://github.com/0x676e67/rquest/pull/387/files#diff-2e9d962a08321605940b5a657135052fbcef87b5e360662bb527c96d9a615542L267-R272)
)examples/impersonate_context.rs
: Renamed fromexamples/impersonate_settings.rs
and updated to useHttpContext
instead ofImpersonateSettings
. ([[1]](https://github.com/0x676e67/rquest/pull/387/files#diff-da1d7807a5d915703c1a9b5533b76995da544ba0c705f5b89c00139ef98f3f81L4-R7)
,[[2]](https://github.com/0x676e67/rquest/pull/387/files#diff-da1d7807a5d915703c1a9b5533b76995da544ba0c705f5b89c00139ef98f3f81L119-R143)
,[[3]](https://github.com/0x676e67/rquest/pull/387/files#diff-da1d7807a5d915703c1a9b5533b76995da544ba0c705f5b89c00139ef98f3f81L183-R189)
,[[4]](https://github.com/0x676e67/rquest/pull/387/files#diff-da1d7807a5d915703c1a9b5533b76995da544ba0c705f5b89c00139ef98f3f81L200-R217)
)examples/impersonate_option.rs
: Renamed fromexamples/impersonate_builder.rs
and updated to useImpersonateOption
. ([[1]](https://github.com/0x676e67/rquest/pull/387/files#diff-74e80d206fe86c8be4742eb98700ec6865c650b57892e6139f08b953a235f299L1-R1)
,[[2]](https://github.com/0x676e67/rquest/pull/387/files#diff-74e80d206fe86c8be4742eb98700ec6865c650b57892e6139f08b953a235f299L10-R19)
)examples/impersonate_psk.rs
: Removed outdated example file. ([examples/impersonate_psk.rsL1-L28](https://github.com/0x676e67/rquest/pull/387/files#diff-546c8eb8b6cdda3bc7faa61040451de011b1c5598823a50c88992f34e23f62c2L1-L28)
)Introducing
HttpContext
:src/client/context.rs
: Added newHttpContext
structure andHttpContextProvider
trait to manage HTTP and TLS configurations. ([src/client/context.rsR1-R55](https://github.com/0x676e67/rquest/pull/387/files#diff-998c828a2b780e77c83f8234103f6cc58b7e6e1ebb026c1d3907f2b9dfce77cfR1-R55)
)Refactoring
ClientBuilder
:src/client/http.rs
: RefactoredClientBuilder
to useHttpContext
for managing configurations, replacingImpersonateSettings
. This includes updates to methods likeimpersonate
,http1_only
,http2_only
, and various TLS configuration methods. ([[1]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L11)
,[[2]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L35-L51)
,[[3]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L113-R114)
,[[4]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L166-R162)
,[[5]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90R186-R209)
,[[6]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L214-L234)
,[[7]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L245-R253)
,[[8]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L324-R332)
,[[9]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L381-R391)
,[[10]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L392-R402)
,[[11]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L755-R771)
,[[12]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L906-R964)
,[[13]](https://github.com/0x676e67/rquest/pull/387/files#diff-5a9090205b95168aa13d30e00f2d23d2e5f2cb231e195f4a56b1775bd6118b90L970-R992)
)### Pull Request Summary