Class: OverSIP::SIP::Response

Inherits:
Message
  • Object
show all
Defined in:
lib/oversip/sip/response.rb,
ext/sip_parser/sip_parser_ruby.c

Constant Summary

Constants inherited from Message

Message::DIALOG_FORMING_METHODS, Message::EMPTY_ARRAY, Message::OUTBOUND_AWARE_METHODS, Message::RECORD_ROUTING_AWARE_METHODS

Instance Attribute Summary collapse

Attributes inherited from Message

#body, #call_id, #connection, #contact, #contact_params, #content_length, #cseq, #from, #from_tag, #hdr_from, #hdr_route, #hdr_to, #hdr_via, #headers, #max_forwards, #num_vias, #proxy_require, #require, #routes, #sip_method, #sip_version, #source_ip, #source_ip_type, #source_port, #supported, #to, #to_tag, #transport, #tvars, #via_branch, #via_branch_id, #via_branch_rfc3261, #via_core_value, #via_has_alias, #via_has_rport, #via_params, #via_received, #via_rport, #via_sent_by_host, #via_sent_by_port

Instance Method Summary collapse

Methods inherited from Message

#append_header, #close_connection, #contact_reg_id?, #delete_header, #delete_header_top, #dialog_forming?, #has_header?, #header_all, #header_top, #insert_header, #outbound_aware?, #record_routing_aware?, #replace_header_top, #set_header, #tcp?, #tls?, #udp?, #unknown_method?, #via_alias?, #via_rport?, #websocket?, #ws?, #wss?

Methods included from Logger

fg_system_msg2str, load_methods, #log_id

Instance Attribute Details

#reason_phraseObject

Returns the value of attribute reason_phrase.



6
7
8
# File 'lib/oversip/sip/response.rb', line 6

def reason_phrase
  @reason_phrase
end

#requestObject

The associated request.



7
8
9
# File 'lib/oversip/sip/response.rb', line 7

def request
  @request
end

#status_codeObject

Returns the value of attribute status_code.



5
6
7
# File 'lib/oversip/sip/response.rb', line 5

def status_code
  @status_code
end

Instance Method Details

#request?Boolean

Returns:

  • (Boolean)


10
# File 'lib/oversip/sip/response.rb', line 10

def request?      ; false        end

#response?Boolean

Returns:

  • (Boolean)


11
# File 'lib/oversip/sip/response.rb', line 11

def response?     ; true         end

#to_sObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/oversip/sip/response.rb', line 14

def to_s
  msg = "SIP/2.0 #{@status_code} #{@reason_phrase}\r\n"

  # Revert changes to From/To headers if modified during the request processing.
  @headers["From"] = [ request.hdr_from ]  if request.from_was_modified
  if request.to_was_modified
    hdr_to = @to_tag ? "#{request.hdr_to};tag=#{@to_tag}" : request.hdr_to
    @headers["To"] = [ hdr_to ]
  end

  @headers.each do |name, values|
    values.each do |value|
      msg << name << ": #{value}\r\n"
    end
  end

  msg << CRLF
  msg << @body  if @body
  msg
end