Class: Cybertrain::Test::ReceivedRequest
- Inherits:
-
Object
- Object
- Cybertrain::Test::ReceivedRequest
- Defined in:
- cybertrain/test/http_receiver.rb
Overview
One request as the receiver read it.
Method names carry an http_ prefix: a framework class that defines
body or headers next to another one returning a different type
confuses Spinel’s inference (spikes/NOTES.md rules 10, 34).
Instance Attribute Summary collapse
-
#http_body ⇒ String
readonly
The body (a chunked body decoded), “” for none.
-
#http_headers ⇒ Hash{String => String}
readonly
Lowercased names; repeated headers joined with “, “.
-
#http_method ⇒ String
readonly
“GET”, “POST”, …
-
#http_target ⇒ String
readonly
The request target as sent: path and query.
Instance Method Summary collapse
-
#http_header(name) ⇒ String
A header’s value by name (any case), “” when it was not sent.
-
#http_path ⇒ String
The target without its query string.
Instance Attribute Details
#http_body ⇒ String (readonly)
Returns the body (a chunked body decoded), “” for none.
30 31 32 |
# File 'cybertrain/test/http_receiver.rb', line 30 def http_body @http_body end |
#http_headers ⇒ Hash{String => String} (readonly)
Returns lowercased names; repeated headers joined with “, “.
26 27 28 |
# File 'cybertrain/test/http_receiver.rb', line 26 def http_headers @http_headers end |
#http_method ⇒ String (readonly)
Returns “GET”, “POST”, …
17 18 19 |
# File 'cybertrain/test/http_receiver.rb', line 17 def http_method @http_method end |
#http_target ⇒ String (readonly)
Returns the request target as sent: path and query.
21 22 23 |
# File 'cybertrain/test/http_receiver.rb', line 21 def http_target @http_target end |
Instance Method Details
#http_header(name) ⇒ String
A header’s value by name (any case), “” when it was not sent.
43 44 45 46 |
# File 'cybertrain/test/http_receiver.rb', line 43 def http_header(name) value = @http_headers[name.to_s.downcase] value.nil? ? "" : value.to_s end |
#http_path ⇒ String
The target without its query string.
51 52 53 54 |
# File 'cybertrain/test/http_receiver.rb', line 51 def http_path at = @http_target.byteindex("?") at.nil? ? @http_target : @http_target.byteslice(0, at) end |