Skip to content

Instantly share code, notes, and snippets.

@adz
Last active December 14, 2015 15:08
Show Gist options
  • Save adz/5105384 to your computer and use it in GitHub Desktop.
Save adz/5105384 to your computer and use it in GitHub Desktop.
require 'net/http' # CODE FROM: https://github.com/mwmitchell/rsolr/blob/master/lib/rsolr/connection.rb
require 'net/https'
# The default/Net::Http adapter for RSolr.
class RSolr::Connection
# using the request_context hash,
# send a request,
# then return the standard rsolr response hash {:status, :body, :headers}
def execute client, request_context
h = http request_context[:uri], request_context[:proxy], request_context[:read_timeout], request_context[:open_timeout]
request = setup_raw_request request_context
request.body = request_context[:data] if request_context[:method] == :post and request_context[:data]
begin
response = h.request request
# I ADDED DEBUG LOG HERE:
puts response.inspect
charset = response.type_params["charset"]
# ... more stuff
# It's expected that h is a Net::HTTP.new instance, and that
# response is the result of doing the HTTP request
# When run from console output is: (expected):
'#<Net::HTTPOK 200 OK readbody=true>'
# When run from a server (wtf is this?):
'[2013-03-07 13:42:55 +1030, #<NewRelic::Agent::StatsEngine::ScopeStackElement:0x2fecc7a9 @name="External/localhost/all", @children_time=0, @deduct_call_time_from_parent=true>]'
# ERROR I was getting was as follows (obviously if you get an array, but how is that coming back?)
'undefined method `type_params' for #<Array:0x7f6a9b19>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment