Faraday::Response::Encoder
Installation
$ git clone https://github.com/Manbo-/faraday-response-encoder
$ cd faraday-response-encoder
$ rake install
Usage
require "faraday/response/encoder"
connection = Faraday.new do |builder|
builder.response :encoder, { from: "EUC-JP", to: "UTF-8", replace: "",
text_only: true, if: ->(env){ ... } }
builder.adapter :net_http
end
connection.get(...).body
Options
from
default: charset value of http headers or UTF-8
specify encoding of response body
to
default: UTF-8
specify value to encode
replace
default: ""
replace invalid bytes with this value
text_only
default: true
if true and response Content-Type doesn't include "text", skip encoding
if
example: if: ->(env){ env[:url].to_s =~ %r(\Ahttp://github.com/) }
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request