Skip to content

Commit

Permalink
Reuse configured middleware stack, sans redirects
Browse files Browse the repository at this point in the history
The changes in 508191d circumvented automatic redirects by building a
one-off Faraday object. This change ensures previously configured
connection options and middleware are reused for that object.
  • Loading branch information
pengwynn committed May 22, 2015
1 parent c66bf00 commit d97eab7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/octokit/client/contents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,18 @@ def archive_link(repo, options={})
format = (options.delete :format) || 'tarball'
url = "#{Repository.path repo}/#{format}/#{repo_ref}"

conn = Faraday.new(:url => @api_endpoint) do |http|
http.headers[:user_agent] = user_agent
conn_opts = @connection_options
conn_opts[:url] = @api_endpoint
conn_opts[:builder] = @middleware.dup if @middleware
conn_opts[:proxy] = @proxy if @proxy
conn = Faraday.new(conn_opts) do |http|
if basic_authenticated?
http.basic_auth(@login, @password)
elsif token_authenticated?
http.authorization 'token', @access_token
end
http.use Octokit::Response::RaiseError
http.adapter Faraday.default_adapter
end
conn.builder.delete(Octokit::Middleware::FollowRedirects)
response = conn.head(url, options)

response.headers['Location']
Expand Down

0 comments on commit d97eab7

Please sign in to comment.