Class: OmniAuth::Eklase::FormMimeTypeFixMiddleware
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- OmniAuth::Eklase::FormMimeTypeFixMiddleware
- Defined in:
- lib/omniauth-eklase/form_mime_type_fix_middleware.rb
Overview
Override the content-type of the response with “application/x-www-form-urlencoded” if the response body looks like it might be a query, e.g.
access_token=74e81934-2a6c-4b91-8e76-f9a616223ed9&expires=3600
Constant Summary collapse
- CONTENT_TYPE =
'Content-Type'.freeze
- MIME_TYPE =
'application/x-www-form-urlencoded'.freeze
- QUERY_REGEX =
/^(\&?[\w\_]+\=[\w\_\-]+)+$/
Instance Method Summary collapse
Instance Method Details
#call(request_env) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/omniauth-eklase/form_mime_type_fix_middleware.rb', line 14 def call(request_env) @app.call(request_env).on_complete do |response_env| if response_env[:body].to_s =~ QUERY_REGEX response_env[:response_headers][CONTENT_TYPE] = MIME_TYPE end end end |