class RTSP::Response

Parses raw response data from the server/client and turns it into attr_readers.

Attributes

body[R]
code[R]
message[R]
rtsp_version[R]

Public Class Methods

new(raw_response) click to toggle source

@param [String] raw_response The raw response string returned from the server/client.

# 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

Public Instance Methods

extract_status_line(line) click to toggle source

Pulls out the RTSP version, response code, and response message (AKA the status line info) into instance variables.

@param [String] line The String containing the status line info.

# 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