Upgrade http.rb gem to 5.0.4.

Fixes a bug where the Foundation source strategy failed because http.rb
automatically sent a `Content-Length: 0` header with all GET requests,
which caused Foundation to return a 400 Bad Request error. This behavior
was fixed in http.rb 5.x.

http.rb 5.x has a breaking change where it now includes the request object
inside the response object, which we have to handle in a few places.
This commit is contained in:
evazion
2022-02-21 17:47:06 -06:00
parent 35dca33abc
commit fbab273c81
8 changed files with 23 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
module IqdbTestHelper
def mock_iqdb_matches(matches)
Danbooru.config.stubs(:iqdb_url).returns("http://localhost:5588")
response = HTTP::Response.new(status: 200, body: matches.to_json, headers: { "Content-Type": "application/json" }, version: "1.1")
response = HTTP::Response.new(status: 200, body: matches.to_json, headers: { "Content-Type": "application/json" }, version: "1.1", request: nil)
HTTP::Client.any_instance.stubs(:post).returns(response)
end
end

View File

@@ -1,6 +1,6 @@
module ReportbooruHelper
def mock_request(url, method: :get, status: 200, body: nil, http: Danbooru::Http.any_instance, **options)
response = HTTP::Response.new(status: status, body: body, version: "1.1")
response = HTTP::Response.new(status: status, body: body, version: "1.1", request: nil)
http.stubs(method).with(url, **options).returns(response)
end