nicoseiga: fix regression with http redirects.

3cdf67920 changed it so that Danbooru::Http follows redirects by
default. This broke some things in the Nico Seiga strategy, so disable
following redirects in the Nico Seiga API client for now.

Also change it so that Danbooru::Http follows redirects after a POST
request (by setting `strict: false`). Nico Seiga needs this because it
sends a redirect after we POST the login form.
This commit is contained in:
evazion
2020-06-15 22:07:41 -05:00
parent 962e60f4f1
commit 7868e5045e
2 changed files with 16 additions and 8 deletions

View File

@@ -6,7 +6,7 @@ module Danbooru
attr_writer :cache, :http
class << self
delegate :get, :put, :post, :delete, :cache, :timeout, :auth, :basic_auth, :headers, to: :new
delegate :get, :put, :post, :delete, :cache, :follow, :timeout, :auth, :basic_auth, :headers, to: :new
end
def get(url, **options)
@@ -29,6 +29,10 @@ module Danbooru
dup.tap { |o| o.cache = expiry.to_i }
end
def follow(*args)
dup.tap { |o| o.http = o.http.follow(*args) }
end
def timeout(*args)
dup.tap { |o| o.http = o.http.timeout(*args) }
end
@@ -77,7 +81,7 @@ module Danbooru
def http
@http ||= ::HTTP.
follow(max_hops: MAX_REDIRECTS).
follow(strict: false, max_hops: MAX_REDIRECTS).
timeout(DEFAULT_TIMEOUT).
use(:auto_inflate).
headers(Danbooru.config.http_headers).