Skip to content

Commit

Permalink
Add support for redirect with cookie authentication
Browse files Browse the repository at this point in the history
In relation to feedreader/pluto#39, the request cookie gets saved for each redirect. This should support cookie based authentication.
  • Loading branch information
pacbard committed Aug 9, 2021
1 parent c115ac7 commit f181bb9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fetcher/lib/fetcher/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def get_response( src )

redirect_limit = 6
response = nil
cookie = nil
cookie_jar = nil

until false
Expand All @@ -165,6 +166,7 @@ def get_response( src )
logger.debug "GET #{uri.request_uri} uri=#{uri}, redirect_limit=#{redirect_limit}"

headers = { 'User-Agent' => "fetcher gem v#{VERSION}" }
headers['Cookie'] = cookie unless cookie.nil?
headers['Cookie'] = cookie_jar unless cookie_jar.nil?

if use_cache?
Expand Down Expand Up @@ -216,6 +218,7 @@ def get_response( src )
newuri = uri + response.header['location']
end
uri = newuri
cookie = response['Set-Cookie']

cookie = response.get_fields('set-cookie')
if cookie.respond_to?('each')
Expand Down

0 comments on commit f181bb9

Please sign in to comment.