mwmitchell/rsolr — Issue #41: base_uri and proxies
Author: whomwah
Created: 2012-02-14 11:28:07+00:00
State: open

Hi,

I was having some strange behaviour with RSolr and proxies. I provided a proxy and the proxy was being used as the actual uri which was causing 400's. I narrowed it down to:

/lib/rsolr/client.rb line 28

def base_uri
@proxy ? @proxy : @uri
end

this method can return a proxy if set, but this method is used below when constructing the :uri option. This means that the proxy uri is used to build the connection path.

def build_request path, opts
...
opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri
...
end

When connection.execute self, request_context gets called

h = http request_context[:uri], request_context[:proxy]

is called, and means that the uri and proxy have the same uri. Am I misunderstanding something here?

Anyway my fix was to do:

def base_uri
@uri
end

which appears to work as expected for me.