Repository navigation
Proxy Support - #153
Proxy Support#153Asmod4n wants to merge 5 commits into
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
endthat 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