Fix undefined method readpartial' for \"\":String` error.
This exception was thrown by app/logical/pixiv_ajax_client.rb:406 when a Pixiv API call failed with a network error. In this case we tried to log the response body, but this failed because we returned a faked HTTP response with an empty string for the body, which the http.rb library didn't like because it was expecting an IO-like object for the body.
This commit is contained in:
@@ -174,17 +174,17 @@ module Danbooru
|
||||
def request(method, url, **options)
|
||||
http.send(method, url, **options)
|
||||
rescue OpenSSL::SSL::SSLError
|
||||
fake_response(590, "")
|
||||
fake_response(590)
|
||||
rescue ValidatingSocket::ProhibitedIpError
|
||||
fake_response(591, "")
|
||||
fake_response(591)
|
||||
rescue HTTP::Redirector::TooManyRedirectsError
|
||||
fake_response(596, "")
|
||||
fake_response(596)
|
||||
rescue HTTP::TimeoutError
|
||||
fake_response(597, "")
|
||||
fake_response(597)
|
||||
rescue HTTP::ConnectionError
|
||||
fake_response(598, "")
|
||||
fake_response(598)
|
||||
rescue HTTP::Error
|
||||
fake_response(599, "")
|
||||
fake_response(599)
|
||||
end
|
||||
|
||||
# Perform a HTTP request for the given URL, raising an error on 4xx or 5xx
|
||||
@@ -205,8 +205,8 @@ module Danbooru
|
||||
end
|
||||
end
|
||||
|
||||
def fake_response(status, body)
|
||||
::HTTP::Response.new(status: status, version: "1.1", body: ::HTTP::Response::Body.new(body))
|
||||
def fake_response(status)
|
||||
::HTTP::Response.new(status: status, version: "1.1", body: "")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user