class Falcon::Adapters::Rewindable
Content-type driven input buffering, specific to the needs of `rack`.
Constants
- BUFFERED_MEDIA_TYPES
Media types that require buffering.
- POST
Public Class Methods
new(app)
click to toggle source
Initialize the rewindable middleware. @parameter app [Protocol::HTTP::Middleware] The middleware to wrap.
Calls superclass method
# File lib/falcon/adapters/rewindable.rb, line 41 def initialize(app) super(app) end
Public Instance Methods
call(request)
click to toggle source
Wrap the request body in a rewindable buffer if required. @parameter request [Protocol::HTTP::Request] @returns [Protocol::HTTP::Response] the response.
Calls superclass method
# File lib/falcon/adapters/rewindable.rb, line 65 def call(request) if body = request.body and needs_rewind?(request) request.body = Async::HTTP::Body::Rewindable.new(body) end return super end
needs_rewind?(request)
click to toggle source
Determine whether the request needs a rewindable body. @parameter request [Protocol::HTTP::Request] @returns [Boolean]
# File lib/falcon/adapters/rewindable.rb, line 48 def needs_rewind?(request) content_type = request.headers['content-type'] if request.method == POST and content_type.nil? return true end if BUFFERED_MEDIA_TYPES =~ content_type return true end return false end