Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Faraday ignore content-type ? #443

Closed
otn opened this issue Dec 17, 2014 · 2 comments
Closed

Does Faraday ignore content-type ? #443

otn opened this issue Dec 17, 2014 · 2 comments

Comments

@otn
Copy link

otn commented Dec 17, 2014

Does Faraday ignore content-type ?

require "faraday"
a = Faraday.new
u = %w|
  http://www.google.com/
  http://www.google.com/search?q=AAAAA
  http://www.google.co.jp/
|
u.each do |x|
  w = a.get(x)
  puts "#{w.status} #{w.body.encoding} #{w.headers['Content-Type']} #{x}"
end
==> 302 UTF-8 text/html; charset=UTF-8 http://www.google.com/
==> 200 ASCII-8BIT text/html; charset=ISO-8859-1 http://www.google.com/search?q=AAAAA
==> 200 ASCII-8BIT text/html; charset=Shift_JIS http://www.google.co.jp/
@technoweenie
Copy link
Member

Faraday depends on the adapters to return the body with the correct encoding. It'd be really nice if net/http (the default adapter) handled this...

@iMacTia
Copy link
Member

iMacTia commented Feb 9, 2017

Hi @otn, I also think this is something outside of Faraday's box.
Low-level encoding and headers parsing should be managed by the adapter and the result of the code above will probably change if you use another one different from the default one (Net::HTTP).

That said, I see the adapter is actually encoding the first response body in UTF-8, meaning that maybe there's some work under there and it's only in case of exotic values that a default ASCII-8BIT is returned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants