-
Notifications
You must be signed in to change notification settings - Fork 322
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
config URI normalization by default #378
Comments
@tarcieri I agree that we should allow enable/disable normalization as well as I think it will make sense to allow use different backends for URI (Addressable::URI / ::URI), so that those who don't want to use addressable (there was an issue for that) would be able to avoid it. |
@mamoonraja there's no planned ETA. PRs are welcome - I'll be happy to help with that. |
@ixti I am working on a PR right now, and I am approaching it in the following way:
# @return [HTTP::URI] URI with all componentes but query being normalized.
def construct_uri(uri, normalize_uri)
uri = HTTP::URI.parse uri
return uri unless normalize_uri
HTTP::URI.new(
:scheme => uri.normalized_scheme,
:authority => uri.normalized_authority,
:path => uri.normalized_path,
:query => uri.query,
:fragment => uri.normalized_fragment
)
end Do you think it's a viable solution without hurting current users? |
What if we would do this via feature instead? Like this: HTTP.use(:uri_normalizer => :itself.to_proc).get(...) By default normalizer will be what we have now. |
I am adding a feature One more query, the way I am adding the feature is that the new feature will handle normalizing the URI, and This will break the users calling HTTP.use(:uri_normalizer => {normalize_uri=>false}).get(...) Does it make sense? I personally favor the first way, handling normalizing the URI inside the feature. But that will be a breaking change. |
I'm not sure I understand.
module HTTP
class Request
# Default uri normalizer
def self.normalize_uri(uri); end
def initialize(opts)
# ...
@uri_normalizer = opts.fetch(:uri_normalizer) { self.class.method(:normalize_uri) }
@uri = @uri_normalizer.call(opts.fetch(:uri))
end
# ...
end
end Something like this
|
We have released v4.1.0 version that allows you to disable URI normalization: normalizer = ->(uri) { ::HTTP::URI.parse(uri) }
HTTP.use(:uri_normalizer => { :normalize => normalizer }).get(...) Notice though that some of the internals depend on |
Hi,
It seems that HTTP gem do URI normalization by default and I can't find the option to change this behavior. I have an application that won't work if HTTP gem do URI normalization. For example, HTTP.get(url) will decode %2B to +
Please let me know if we can control the URI normalization or not. Thank you!
The text was updated successfully, but these errors were encountered: