diff --git a/app/models/symphony_reader.rb b/app/models/symphony_reader.rb index eb0cf729a..1c4c2e058 100644 --- a/app/models/symphony_reader.rb +++ b/app/models/symphony_reader.rb @@ -9,11 +9,11 @@ class ResponseError < StandardError; end attr_reader :catkey def self.client - Faraday.new(headers: Settings.catalog.symphony.headers) # do |conn| - # conn.request :url_encoded - # conn.use FaradayMiddleware::Chunked - # conn.adapter :net_http - # end + Faraday.new(headers: Settings.catalog.symphony.headers) do |conn| + conn.request :url_encoded + conn.response :chunked + conn.adapter :net_http + end end def initialize(catkey:) @@ -49,21 +49,21 @@ def client def symphony_response resp = client.get(format(Settings.catalog.symphony.json_url, catkey: catkey)) - if resp.headers['transfer-encoding'] == 'chunked' - streamed = [] - - client.get(format(Settings.catalog.symphony.json_url, catkey: catkey)) do |req| - # Set a callback which will receive tuples of chunk Strings - # and the sum of characters received so far - req.options.on_data = Proc.new do |chunk, overall_received_bytes| - puts "Received #{overall_received_bytes} characters" - streamed << chunk - end - end - - resp.body = streamed.join - resp.status = 200 - end + # if resp.headers['transfer-encoding'] == 'chunked' + # streamed = [] + # + # client.get(format(Settings.catalog.symphony.json_url, catkey: catkey)) do |req| + # # Set a callback which will receive tuples of chunk Strings + # # and the sum of characters received so far + # req.options.on_data = Proc.new do |chunk, overall_received_bytes| + # puts "Received #{overall_received_bytes} characters" + # streamed << chunk + # end + # end + # + # resp.body = streamed.join + # resp.status = 200 + # end if resp.status == 200 validate_response(resp)