Class: SWS::Response
- Inherits:
-
Object
- Object
- SWS::Response
- Defined in:
- lib/sws/response.rb
Overview
Represents HTML reponse generated by SWS
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#cookies ⇒ Object
readonly
Array of Cookie objects.
-
#headers ⇒ Object
readonly
Hash of HTTP headers.
-
#http_version ⇒ Object
The version of HTTP protocol.
-
#request ⇒ Object
readonly
The Request the receiver is associated with.
-
#status ⇒ Object
Status of the response.
Class Method Summary collapse
Instance Method Summary collapse
-
#<<(string) ⇒ Object
Appends a string to the receiver.
-
#initialize(request, status = "200 SWS/OK") ⇒ Response
constructor
Creates new empty Response object.
-
#to_s ⇒ Object
Returns string representation of the receiver.
Constructor Details
#initialize(request, status = "200 SWS/OK") ⇒ Response
Creates new empty Response object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/sws/response.rb', line 29 def initialize ( request,status = "200 SWS/OK" ) @content = "" @headers = Hash.new @cookies = Array.new @http_version = "HTTP/1.1" @status = status @request = request end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
25 26 27 |
# File 'lib/sws/response.rb', line 25 def content @content end |
#cookies ⇒ Object (readonly)
Array of Cookie objects
14 15 16 |
# File 'lib/sws/response.rb', line 14 def @cookies end |
#headers ⇒ Object (readonly)
Hash of HTTP headers
11 12 13 |
# File 'lib/sws/response.rb', line 11 def headers @headers end |
#http_version ⇒ Object
The version of HTTP protocol
17 18 19 |
# File 'lib/sws/response.rb', line 17 def http_version @http_version end |
#request ⇒ Object (readonly)
The Request the receiver is associated with
23 24 25 |
# File 'lib/sws/response.rb', line 23 def request @request end |
#status ⇒ Object
Status of the response
20 21 22 |
# File 'lib/sws/response.rb', line 20 def status @status end |
Class Method Details
Instance Method Details
#<<(string) ⇒ Object
Appends a string to the receiver
49 50 51 |
# File 'lib/sws/response.rb', line 49 def << ( string ) @content << string end |
#to_s ⇒ Object
Returns string representation of the receiver
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/sws/response.rb', line 55 def to_s () data = "" @headers.each_pair { |key, value| data << "#{key}: #{value}\r\n" } @cookies.each { || data << "#{}\r\n" } # End headers data << "\r\n" data << @content return data end |