Method: Rex::Proto::SIP::Response.parse

Defined in:
lib/rex/proto/sip/response.rb

.parse(data) ⇒ Object

Parses data, constructs and returns a Response



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rex/proto/sip/response.rb', line 45

def self.parse(data)
  response = Response.new
  # do some basic sanity checking on this response to ensure that it is SIP
  response.status_line = data.split(/\r\n/)[0]
  unless response.status_line && response.status_line =~ SIP_STATUS_REGEX
    fail(ArgumentError, "Invalid SIP status line: #{response.status_line}")
  end
  response.version = Regexp.last_match(1)
  response.code = Regexp.last_match(2)
  response.message = Regexp.last_match(3)
  response.headers = extract_headers(data)
  response
end