lib/rtsp/response.rb
# Reads through each header line of the RTSP response, extracts the
# response code, response message, response version, and creates a
# snake-case accessor with that value set.
#
# @param [String] head The section of headers from the response text.
Reads through each header line of the RTSP response, extracts the
response code, response message, response version, and creates a
snake-case accessor with that value set.
Reads through each header line of the RTSP response extracts the response code response message response version and creates a snake - case accessor with that value set .
def parse_head head
      lines = head.split "\r\n"
      lines.each_with_index do |line, i|
        if i == 0
          extract_status_line(line)
          next
        end
        if line.include? "Session: "
          value = {}
          line =~ /Session: ([\w\\$\-\.\+]+)/
          value[:session_id] = $1
          if line =~ /timeout=(.+)/
            value[:timeout] = $1.to_i
          end
          create_reader("session", value)
        elsif line.include? ": "
          header_and_value = line.strip.split(":", 2)
          header_name = header_and_value.first.downcase.gsub(/-/, "_")
          create_reader(header_name, header_and_value[1].strip)
        end
      end
    end
def parse_head head lines = head . split "\r\n" lines . each_with_index do | line , i | if i == 0 extract_status_line ( line ) next end if line . include? "Session: " value = { } line =~ / Session: ([ \w \\ $ \- \. \+ ]+) / value [ :session_id ] = $1 if line =~ / timeout=(.+) / value [ :timeout ] = $1 . to_i end create_reader ( "session" , value ) elsif line . include? ": " header_and_value = line . strip . split ( ":" , 2 ) header_name = header_and_value . first . downcase . gsub ( / - / , "_" ) create_reader ( header_name , header_and_value [ 1 ] . strip ) end end end
Reads through each header line of the RTSP response, extracts the
response code, response message, response version, and creates a
snake-case accessor with that value set.
Reads through each header line of the RTSP response extracts the response code response message response version and creates a snake - case accessor with that value set .
head
head The section of headers from the response text.
head The section of headers from the response text .