danbooru::http: factor out referrer spoofing.
Factor out referrer spoofing so that it can be used outside of downloading files. We also need to spoof the referrer when determining the remote filesize of images on the uploads page.
This commit is contained in:
@@ -127,6 +127,15 @@ class DanbooruHttpTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "spoof referrer feature" do
|
||||
should "spoof the referer" do
|
||||
response = Danbooru::Http.get("https://httpbin.org/anything")
|
||||
|
||||
assert_equal(200, response.status)
|
||||
assert_equal("https://httpbin.org", response.parse.dig("headers", "Referer"))
|
||||
end
|
||||
end
|
||||
|
||||
context "#download method" do
|
||||
should "download files" do
|
||||
response, file = Danbooru::Http.download_media("https://httpbin.org/bytes/1000")
|
||||
|
||||
Reference in New Issue
Block a user