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:
evazion
2020-06-24 20:52:29 -05:00
parent f84ceb3938
commit d3bb5c67ee
3 changed files with 25 additions and 2 deletions

View File

@@ -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")