Class: ActionDispatch::RequestBody

Inherits:
Object
  • Object
show all
Defined in:
runtime/action_dispatch/request.rb,
runtime/action_dispatch/request.rbs

Overview

the raw body as an IO, not the String. Callers rewind and read it (request.body.rewind; request.body.read), which a String cannot answer. The bytes Tep read are the storage; this is the cursor over them, exposing the subset of Rack's input a controller reaches: rewind, read, string, size, eof?.

Not StringIO: a request body needs one method each, not a stdlib class.

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ RequestBody

Returns a new instance of RequestBody.

Parameters:



5
# File 'runtime/action_dispatch/request.rbs', line 5

def initialize: (String text) -> void

Instance Method Details

#eof? ⇒ Boolean

Returns:

  • (Boolean)


11
# File 'runtime/action_dispatch/request.rbs', line 11

def eof?: () -> bool

#length ⇒ Integer

Returns:



10
# File 'runtime/action_dispatch/request.rbs', line 10

def length: () -> Integer

#read ⇒ String

from the cursor to the end, as Ruby's IO#read with no length; a second read at the end is "" (not nil — that is the read(length) form's answer, which no caller here spells). The cursor counts characters, not bytes: only the whole-body read is served, so the two agree on everything a caller can observe.

Returns:

  • (String) —

    the remaining body, "" once it has all been read



39
# File 'runtime/action_dispatch/request.rb', line 39

def read: () -> String

#rewind ⇒ Integer

Returns:



7
# File 'runtime/action_dispatch/request.rbs', line 7

def rewind: () -> Integer

#size ⇒ Integer

Returns:



9
# File 'runtime/action_dispatch/request.rbs', line 9

def size: () -> Integer

#string ⇒ String

the whole body as a String, whatever the cursor says — Rack's StringIO#string, and what raw_post is built on.

Returns:

  • (String) —

    the entire body, cursor position ignored



24
# File 'runtime/action_dispatch/request.rb', line 24

def string: () -> String