253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
|
# File 'app/service_adaptors/google_book_search.rb', line 253
def do_query(bibkeys, request)
= (request)
link = @url + bibkeys
if @api_key
link += "&key=#{@api_key}"
end
link += "&printType=books"
Rails.logger.debug("GoogleBookSearch requesting: #{link}")
response = http_fetch(link, :headers => , :raise_on_http_error_code => false)
data = MultiJson.load(response.body)
if (data["error"] && data["error"]["errors"] &&
data["error"]["errors"].find {|h| h["reason"] == "unknownLocation"} )
Rails.logger.warn("GoogleBookSearch: geo-locate error, retrying without X-Forwarded-For: '#{link}' headers: #{.inspect} #{response.inspect}\n #{data.inspect}")
response = http_fetch(link, :raise_on_http_error_code => false)
data = MultiJson.load(response.body)
end
if (! response.kind_of?(Net::HTTPSuccess)) || data["error"]
Rails.logger.error("GoogleBookSearch error: '#{link}' headers: #{.inspect} #{response.inspect}\n #{data.inspect}")
end
return data
end
|