-
Notifications
You must be signed in to change notification settings - Fork 983
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
Faraday tries to modify frozen URI (FrozenError) #1349
Comments
Thanks for reporting this @sled, no I would say this is not intended! It seems like a simple overlooking. I believe there should be a |
That's a good point, and it also makes sense if we think about it. A simple library should not worry about this kind of stuff, stay simple and do the bare minimum. Shall we agree this should be a |
I found some inconsistency regarding the It is documented as being a string here but it's expected to be URI-like here, here, here and here Also, the That's not the case with I could imagine three options: Keep the URI frozen
This way, Faraday would work as expected, however explicit calls to URI setters like Duplicating the URI
Converting to a string first
On a side note, the regex to check for a trailing slash |
@sled thanks for the deep analysis and for spotting these inconsistencies! I can only imagine this is the result of years of "patching" the code over and over again 😅. I'd personally opt for a simple solution right now, either using So if that's OK with you, I'd go with one of the simple solutions (maybe the
These sound like great improvements, I'd be happy to have them included in the PR 👍 |
+1. I recently ran into a situation where passing a |
Ruby Version = 3.0.2
Faraday Version = 1.8.0, 2.0.0
If a frozen URI is passed, Faraday tries to modify the URL and a
FrozenError: can't modify frozen URI::HTTP: #<URI::HTTP http://example.org/api/v1>
is raised.The affected code sections
v1.8.0 https://github.com/lostisland/faraday/blob/v1.8.0/lib/faraday/connection.rb#L448-L459
v2.0.0 https://github.com/lostisland/faraday/blob/main/lib/faraday/connection.rb#L448-L459
Minimal code sample:
Is this behaviour intended?
The text was updated successfully, but these errors were encountered: