Skip to content

Commit

Permalink
Handle redirects when Rack::Compatibility is off
Browse files Browse the repository at this point in the history
This fixes crohr#17
  • Loading branch information
dmargery committed Jun 27, 2018
1 parent e609a84 commit 560091d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/restclient/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,18 @@ def to_hash
env['restclient.hash'][:error] = e
response = e.response
end
# to satisfy Rack::Lint
response.headers.delete(:status)
header = RestClient.debeautify_headers( response.headers )
body = response.to_s
# return the real content-length since RestClient does not do it when
# decoding gzip responses
header['Content-Length'] = body.length.to_s if header.has_key?('Content-Length')
[response.code, header, [body]]
if response.is_a?(RestClient::Response)
# to satisfy Rack::Lint
response.headers.delete(:status)
header = RestClient.debeautify_headers( response.headers )
body = response.to_s
# return the real content-length since RestClient does not do it when
# decoding gzip responses
header['Content-Length'] = body.length.to_s if header.has_key?('Content-Length')
[response.code, header, [body]]
else
response
end
}

end

0 comments on commit 560091d

Please sign in to comment.