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

Additional cookie features #215

Closed
Anonymus1 opened this issue Jul 24, 2020 · 2 comments
Closed

Additional cookie features #215

Anonymus1 opened this issue Jul 24, 2020 · 2 comments
Assignees
Labels
enhancement Make a feature better
Milestone

Comments

@Anonymus1
Copy link

Allow reading of current stored cookies with something like a client.get_cookies() function.

@sagebind sagebind added the enhancement Make a feature better label Jul 24, 2020
@sagebind
Copy link
Owner

sagebind commented Jul 24, 2020

It may also be nice to expose the cookie parsing capability without necessarily enabling the cookie jar, so that you could do something like response.cookies() to inspect the parsed results of Set-Cookie headers, and something like request.cookies_mut().insert(cookie) to add a custom Cookie header in a more convenient way.

We'll have to expose some details of the Cookie struct in the API for these additions to work. Currently the struct members are all private with no public methods.

@sagebind sagebind added this to the 1.0 milestone Jul 29, 2020
@sagebind sagebind mentioned this issue Jul 29, 2020
8 tasks
@sagebind sagebind self-assigned this Oct 8, 2020
sagebind added a commit that referenced this issue Oct 9, 2020
Work in progress.

See #215.
sagebind added a commit that referenced this issue Oct 11, 2020
Implement an interceptors API and remove the old middleware API.

The new interceptors API is gated behind the `unstable-interceptors` feature flag. We sort of need to rush this out the door in order to implement #215 properly, but we're not ready to finalize the design yet. There are still some open problems to fix with this:

- `from_fn` doesn't work as desired. The trait bounds are too ambiguous for the compiler to infer for closures, and since the return type is generic over a lifetime, there's no way to give the return type the correct name using current Rust syntax.
- `InterceptorObj` wraps the returned future in an extra box.
- If an interceptor returns a custom error, it is stringified and wrapped in `Error::Curl`. We should introduce a new error variant that boxes the error and also records the type of the interceptor that created the error for visibility.
- Automatic redirect following currently bypasses interceptors for subsequent requests. This will be fixed when redirect handling is rewritten as an interceptor itself. See #232.

Users who are eager for interceptors can also opt-in to this feature and start experimenting if they can't wait for stabilization.

Related: #42
sagebind added a commit that referenced this issue Oct 18, 2020
Expose a public API for setting a cookie jar and accessing it again for clients, requests, and responses. This is not a complete API solution to solve #215, but it gets us closer.

This also includes a major internal refactoring of the cookie jar and cookie parsing which will help us with solidifying the desired API.
@sagebind
Copy link
Owner

sagebind commented Nov 3, 2020

A minimal API for this is now available in the 0.9.11 release! It is limited to the basics of accessing cookies in the cookie jar by URI and name, though in the future we can expand the API to do more things, such as creating and persisting artificial cookies, getting cookie attributes, etc.

@sagebind sagebind closed this as completed Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make a feature better
Projects
None yet
Development

No branches or pull requests

2 participants