Skip to content

Instantly share code, notes, and snippets.

@keolo
Created May 21, 2010 19:44
Show Gist options
  • Save keolo/409322 to your computer and use it in GitHub Desktop.
Save keolo/409322 to your computer and use it in GitHub Desktop.
# Add http basic authentication to rsolr v0.12.1
class RSolr::Connection::NetHttp
def get_request(url)
req = Net::HTTP::Get.new(url)
req.basic_auth(@uri.user, @uri.password) if @uri.user && @uri.password
self.connection.request(req)
end
def post_request(url, data, headers)
req = Net::HTTP::Post.new(url, headers)
req.basic_auth(@uri.user, @uri.password) if @uri.user && @uri.password
self.connection.request(req, data)
end
def get(path, params={})
url = self.build_url(path, params)
net_http_response = self.get_request(url)
create_http_context(net_http_response, url, path, params)
end
def post(path, data, params={}, headers={})
url = self.build_url(path, params)
net_http_response = self.post_request(url, data, headers)
create_http_context(net_http_response, url, path, params, data, headers)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment