Sha256: 4f149524af0e5b01ce5ed996cf3ce19f20888b28a2dd9f50d8bf956db174fea2
Contents?: true
Size: 884 Bytes
Versions: 1
Compression:
Stored size: 884 Bytes
Contents
# This is taken from https://github.com/ma2gedev/faraday-encoding, # all credits for this goes to Takayuki Matsubara (takayuki.1229+github@gmail.com). # We should be able to switch to the original gem when # this PR (https://github.com/ma2gedev/faraday-encoding/pull/2) is merged. module Faraday class Faraday::Encoding < Faraday::Middleware def call(environment) @app.call(environment).on_complete do |env| @content_charset = nil if /;\s*charset=\s*(.+?)\s*(;|$)/.match(env[:response_headers][:content_type]) encoding = $1 encoding = 'utf-8' if encoding == 'utf8' # this is the actual fix @content_charset = ::Encoding.find encoding rescue nil end env[:body].force_encoding @content_charset if @content_charset end end end end Faraday::Response.register_middleware :encoding => Faraday::Encoding
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webhook_system-1.0.2 | lib/faraday_middleware/encoding.rb |