Class: ActionDispatch::RequestBody
- 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
- #eof? ⇒ Boolean
-
#initialize(text) ⇒ RequestBody
constructor
A new instance of RequestBody.
- #length ⇒ Integer
-
#read ⇒ String
from the cursor to the end, as Ruby's
IO#readwith no length; a second read at the end is "" (not nil — that is theread(length)form's answer, which no caller here spells). - #rewind ⇒ Integer
- #size ⇒ Integer
-
#string ⇒ String
the whole body as a String, whatever the cursor says — Rack's
StringIO#string, and whatraw_postis built on.
Constructor Details
#initialize(text) ⇒ RequestBody
Returns a new instance of RequestBody.
5 |
# File 'runtime/action_dispatch/request.rbs', line 5
def initialize: (String text) -> void
|
Instance Method Details
#eof? ⇒ Boolean
11 |
# File 'runtime/action_dispatch/request.rbs', line 11
def eof?: () -> bool
|
#length ⇒ Integer
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.
39 |
# File 'runtime/action_dispatch/request.rb', line 39
def read: () -> String
|
#string ⇒ String
the whole body as a String, whatever the cursor says — Rack's
StringIO#string, and what raw_post is built on.
24 |
# File 'runtime/action_dispatch/request.rb', line 24
def string: () -> String
|