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

refactor: Improve client API design and documentation #387

Merged
merged 3 commits into from
Jan 29, 2025
Merged

refactor: Improve client API design and documentation #387

merged 3 commits into from
Jan 29, 2025

Conversation

0x676e67
Copy link
Owner

@0x676e67 0x676e67 commented Jan 29, 2025

This pull request includes significant changes to the rquest library, focusing on renaming example files, updating configurations, and introducing a new HttpContext structure. The most important changes include renaming and updating examples, refactoring the ClientBuilder to use HttpContext, 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 from examples/impersonate_settings.rs and updated to use HttpContext instead of ImpersonateSettings. ([[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 from examples/impersonate_builder.rs and updated to use ImpersonateOption. ([[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 new HttpContext structure and HttpContextProvider 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: Refactored ClientBuilder to use HttpContext for managing configurations, replacing ImpersonateSettings. This includes updates to methods like impersonate, 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

@0x676e67 0x676e67 changed the title refactor: Refactor client http1/http2/tls configuration usage refactor: Improve API design and documentation Jan 29, 2025
@0x676e67 0x676e67 changed the title refactor: Improve API design and documentation refactor: Improve client API design and documentation Jan 29, 2025
@0x676e67 0x676e67 merged commit 7a63ba6 into main Jan 29, 2025
4 checks passed
@0x676e67 0x676e67 deleted the ref branch January 29, 2025 14:31
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.

1 participant