Class: Stub::Request
- Inherits:
-
Object
- Object
- Stub::Request
- Defined in:
- lib/uaa/stub/server.rb
Overview
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#completed?(str) ⇒ Boolean
adds data to the request, returns true if request is complete.
- #cookies ⇒ Object
-
#initialize ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize ⇒ Request
Returns a new instance of Request.
31 |
# File 'lib/uaa/stub/server.rb', line 31 def initialize; @state, @prelude = :init, "" end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
30 31 32 |
# File 'lib/uaa/stub/server.rb', line 30 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
30 31 32 |
# File 'lib/uaa/stub/server.rb', line 30 def headers @headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
30 31 32 |
# File 'lib/uaa/stub/server.rb', line 30 def method @method end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
30 31 32 |
# File 'lib/uaa/stub/server.rb', line 30 def path @path end |
Instance Method Details
#completed?(str) ⇒ Boolean
adds data to the request, returns true if request is complete
68 69 70 71 72 73 74 75 |
# File 'lib/uaa/stub/server.rb', line 68 def completed?(str) str, @prelude = @prelude + str, "" unless @prelude.empty? add_lines(str) return unless @state == :body && @body.bytesize >= @content_length @prelude = bslice(@body, @content_length..-1) @body = bslice(@body, 0..@content_length) @state = :init end |
#cookies ⇒ Object
77 78 79 80 81 82 83 |
# File 'lib/uaa/stub/server.rb', line 77 def return {} unless chdr = @headers["cookie"] chdr.strip.split(/\s*;\s*/).each_with_object({}) do |pair, o| k, v = pair.split(/\s*=\s*/) o[k.downcase] = v end end |