Created
May 21, 2010 19:44
-
-
Save keolo/409322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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