class Faraday::Request::UrlEncoded
Constants
- CONTENT_TYPE
Attributes
mime_type[RW]
Public Instance Methods
call(env)
click to toggle source
# File lib/faraday/request/url_encoded.rb, line 10 def call(env) match_content_type(env) do |data| params = Faraday::Utils::ParamsHash[data] env.body = params.to_query(env.params_encoder) end @app.call env end
match_content_type(env) { |body| ... }
click to toggle source
# File lib/faraday/request/url_encoded.rb, line 18 def match_content_type(env) if process_request?(env) env.request_headers[CONTENT_TYPE] ||= self.class.mime_type yield(env.body) unless env.body.respond_to?(:to_str) end end
process_request?(env)
click to toggle source
# File lib/faraday/request/url_encoded.rb, line 25 def process_request?(env) type = request_type(env) env.body and (type.empty? or type == self.class.mime_type) end
request_type(env)
click to toggle source
# File lib/faraday/request/url_encoded.rb, line 30 def request_type(env) type = env.request_headers[CONTENT_TYPE].to_s type = type.split(';', 2).first if type.index(';') type end