reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Add base url option to ClientBuilder

Open thomasqueirozb opened this issue 2 years ago • 11 comments

Closes #213, closes #988

There is still one possible problem with this implementation that I don't know if it should be addressed or not.

If the base_url is set to: http://example.com and the Client makes a request to a (not /a), it would make a request to http://example.coma. I could easily add a check to see if the string ends with / and if it's not there I just add it. However, if I implement this, and we consider the same scenario, then a get to /a would actually make a request to http://example.com//a (note the double /). I could implement a check for this too and check for a string beginning with / and remove it if so.

I didn't do any of these because I didn't want to make this PR unnecessarily complex and/or implement something that a user would consider unexpected behavior without hearing any feedback first.

Edit: I implemented these checks over at base_url_check

thomasqueirozb avatar Sep 08 '22 22:09 thomasqueirozb

After using my own fork, I found it better to use this with those checks so I merged them into this PR

thomasqueirozb avatar Dec 08 '22 22:12 thomasqueirozb

This PR would also close #988.

dfaust avatar Dec 20 '22 18:12 dfaust

Any updates?

lennartkloock avatar Mar 03 '23 14:03 lennartkloock

What can we do to land this?

merlindru avatar Jul 14 '23 08:07 merlindru

Any updates on this?

ce7elem avatar Dec 01 '23 09:12 ce7elem

Just rebased the branch. This is now over a year old.

Can we get this reviewed & merged? @seanmonstar

thomasqueirozb avatar Dec 02 '23 00:12 thomasqueirozb

Just commenting to raise some noise/visibility for this PR.

It's a common feature for http clients. In Javascript the feature is available in axios and in Java you can find the feature in the SpringBoot RestTemplate as well as RestClient.

Thank you @thomasqueirozb !

justin-lyon avatar Dec 20 '23 02:12 justin-lyon

Looking for this feature too. If you prefer not adding this feature, can you tell why? I'm cerious

thewh1teagle avatar Jan 02 '24 17:01 thewh1teagle

Since this doesn't look like its going to be merged anytime soon you can use my fork like so:

reqwest = { git = "https://github.com/thomasqueirozb/reqwest", branch = "base_url" }

If you want to use cookies you'll have to use my own fork of reqwest_cookie_store too

reqwest = { git = "https://github.com/thomasqueirozb/reqwest", branch = "base_url", features = ["cookies"] }
reqwest_cookie_store = { git = "https://github.com/thomasqueirozb/reqwest_cookie_store" }

I periodically update the forks with the master branch of reqwest

thomasqueirozb avatar Jan 20 '24 23:01 thomasqueirozb

Would also love to see this shipped. Great work @thomasqueirozb!

jamievaughan avatar Feb 07 '24 14:02 jamievaughan

Hi, any updates on this feature?

IgnisDa avatar Jun 17 '24 08:06 IgnisDa