Class: RecipeScrapers::Http::Encoding
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- RecipeScrapers::Http::Encoding
- Defined in:
- lib/recipe_scrapers/http/encoding.rb
Overview
Converts a response body to UTF-8, using the charset of the Content-Type header or of the meta
tag in the first 4 KiB. Invalid bytes are replaced. Registered as :recipe_scrapers_encoding.
Instance Method Summary collapse
- #on_complete(env) ⇒ void private
Instance Method Details
#on_complete(env) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
19 20 21 22 23 24 |
# File 'lib/recipe_scrapers/http/encoding.rb', line 19 def on_complete(env) body = env[:body] return if body.nil? || body.empty? env[:body] = to_utf8(body, charset_from(env[:response_headers]) || (body)) end |