Class: RTSP::Response
Overview
Parses raw response data from the server/client and turns it into attr_readers.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#rtsp_version ⇒ Object
readonly
Returns the value of attribute rtsp_version.
Instance Method Summary collapse
-
#extract_status_line(line) ⇒ Object
Pulls out the RTSP version, response code, and response message (AKA the status line info) into instance variables.
-
#initialize(raw_response) ⇒ Response
constructor
server/client.
Methods included from Common
#inspect, #multicast?, #parse_body, #parse_head, #split_head_and_body_from, #to_s, #transport_url
Constructor Details
#initialize(raw_response) ⇒ Response
server/client.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rtsp/response.rb', line 19 def initialize(raw_response) if raw_response.nil? || raw_response.empty? raise RTSP::Error, "#{self.class} received nil string--this shouldn't happen." end @raw_body = raw_response head, body = split_head_and_body_from @raw_body parse_head(head) @body = parse_body(body) end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
15 16 17 |
# File 'lib/rtsp/response.rb', line 15 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
13 14 15 |
# File 'lib/rtsp/response.rb', line 13 def code @code end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
14 15 16 |
# File 'lib/rtsp/response.rb', line 14 def @message end |
#rtsp_version ⇒ Object (readonly)
Returns the value of attribute rtsp_version.
12 13 14 |
# File 'lib/rtsp/response.rb', line 12 def rtsp_version @rtsp_version end |
Instance Method Details
#extract_status_line(line) ⇒ Object
Pulls out the RTSP version, response code, and response message (AKA the status line info) into instance variables.
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rtsp/response.rb', line 36 def extract_status_line(line) line =~ /RTSP\/(\d\.\d) (\d\d\d) ([^\r\n]+)/ @rtsp_version = $1 @code = $2.to_i @message = $3 if @rtsp_version.nil? raise RTSP::Error, "Status line corrupted: #{line}" end end |