-
Notifications
You must be signed in to change notification settings - Fork 54
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
Proxy Support #153
Proxy Support #153
Conversation
Webmachine::Headers[‘foo’] always returns something, even when its not what was requested oO
Something is borked with https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/headers.rb#L31 or https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/headers.rb#L35 when used in https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/request.rb headers['whatever'] always returns the first entry no matter what its named |
replying to a5550a2#commitcomment-5464134 |
shrug would still involve class vars or rewriting of each adapter. |
it doesn't have to involve class variables. class Webmachine::Application # last time i write this tonight
class << self
attr_accessor :proxy_support
end
end that example uses an instance variable. it can be localized in an instance of class Webmachine::Request
def initialize(*)
if Application.proxy_support
…
end
end
end |
it's a possible simple solution to the problem because if one application changes global state then the other won't see it, as is probably intended. that means the global state becomes a "default" but that the application owns it once you create an instance of it. |
Meaning you have to change https://github.com/seancribbs/webmachine-ruby/blob/master/lib/webmachine/request.rb#L33 to def initialize(method, uri, headers, body, configuration) and have each adapter do this: Webmachine::Request.new(method, uri, wm_headers, request.body, configuration) because thats the only place you can get a hold of that variable. doing @configuration = Adapter.configuration.dup inside Webmachine::Request means you always get the newest configuration from another instance of Webmachine::Application. |
yeah, you have to change Request to accept an instance of Application. it's a backwards incompatible change. if you're uncomfortable with that maybe @seancribbs has some ideas. it feels okay to me because the instance of Request is always local to an instance of Application, so forwarding on what is already local to keep stuff local seems okay. |
btw i would probably just pass an instance of |
Have changed webrick that way, will go to sleep now ^^ |
sleep well! |
Added two new Configuration options, :runs_behind_proxy and :trusted_headers, when :runs_behind_proxy is set to true each new Request filters the headers Hash and modifies the request.uri in Webmachine::Request