Sha256: d4f5e8b81f2fadc71c29cb0531daa44d38f6cc39309bccbd6480bee6079763ae
Contents?: true
Size: 751 Bytes
Versions: 2
Compression:
Stored size: 751 Bytes
Contents
module OmniAuth module Eklase # 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 # class FormMimeTypeFixMiddleware < Faraday::Middleware CONTENT_TYPE = 'Content-Type'.freeze MIME_TYPE = 'application/x-www-form-urlencoded'.freeze QUERY_REGEX = /^(\&?[\w\_]+\=[\w\_\-]+)+$/ 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omniauth-eklase-2.0.0 | lib/omniauth-eklase/form_mime_type_fix_middleware.rb |
omniauth-eklase-1.0.0 | lib/omniauth-eklase/form_mime_type_fix_middleware.rb |