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

Feature request: Allow running a request with changed configuration #821

Closed
ConradIrwin opened this issue Sep 26, 2024 · 4 comments · Fixed by #823
Closed

Feature request: Allow running a request with changed configuration #821

ConradIrwin opened this issue Sep 26, 2024 · 4 comments · Fixed by #823

Comments

@ConradIrwin
Copy link
Contributor

I'm looking into Ureq as a replacement for isahc, and one thing we're missing is a nice way to set per-request read timeouts.

I see that in 3.x timeouts can be overridden per request, but only if we go through the Ureq builder. We can do this, but it'd be nice to preserve the current API where we get passed an http::Request<X> and we pass it on down. I tried to create some helper functions where we matched on the method, and called the appropriate builder function; but it looks like the WithBody/WithoutBody types are not exposed, so I can't easily do that.

As you make progress on the v3, it'd be nice to have something like:

agent.request(method: Method) -> RequestBuilder<WithBody>
@algesten
Copy link
Owner

Hi @ConradIrwin and welcome to ureq!

Interesting problem and it is an oversight, the per-request config is quite new. Maybe we can do something like:

impl Agent {
    pub fn configure_request(&self, request: Request<impl AsSendBody>) -> &mut AgentConfig { ... }
}

@algesten
Copy link
Owner

The name AgentConfig is increasingly weird with more of these request-level configurations.

@ConradIrwin
Copy link
Contributor Author

That'd be great!

I am currently building on Ureq 2.x, and just maintaining a pool of agents depending on the timeout (because in reality the connection pool is only helpful when connecting to the same host, and my timeouts are per host).

How "ready" is the 3 branch? If you're at the point you want some production testing, I'd be happy to upgrade now; but if you think we need to wait a bit, I can do that :D.

@algesten
Copy link
Owner

How "ready" is the 3 branch? If you're at the point you want some production testing, I'd be happy to upgrade now; but if you think we need to wait a bit, I can do that :D.

My plan is to release the 3.0.0-rc1 ASAP. It's mostly held back by that I think I need to write some migration doc. I'm using the main branch in production at work, but it would be great to get feedback on how it works for others too.

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 a pull request may close this issue.

2 participants