lib/oversip/sip/request.rb in oversip-1.3.8 vs lib/oversip/sip/request.rb in oversip-1.4.0

- old
+ new

@@ -102,10 +102,40 @@ send_response(response_leg_a) true end + # RFC 6228 (199 response). + def reply_199 response + # Store the previous internal To-tag (if set). + internal_to_tag = @internal_to_tag + + # Set it with the To-tag of the response for which a 199 must eb generated. + @internal_to_tag = response.to_tag + + # Send the 199 response. + reply 199, "Early Dialog Terminated", [ "Reason: SIP ;cause=#{response.status_code} ;text=\"#{response.reason_phrase}\"" ] + + # Restore the previous internal To-tag. + @internal_to_tag = internal_to_tag + true + end + private :reply_199 + + + def ruri= ruri + case ruri + when ::OverSIP::SIP::Uri, ::OverSIP::SIP::NameAddr + @ruri = ruri + when ::String + @ruri = OverSIP::SIP::Uri.parse ruri + else + raise ::OverSIP::RuntimeError, "invalid URI #{ruri.inspect}" + end + end + + def send_response(response) unless (case @transport when :udp @connection.send_sip_msg response, @source_ip, @via_rport || @via_sent_by_port || 5060 else @@ -116,10 +146,10 @@ end end def to_s - msg = "#{@sip_method.to_s} #{self.ruri.uri} SIP/2.0\r\n" + msg = "#{@sip_method.to_s} #{@ruri.uri} SIP/2.0\r\n" # Update From/To/Contact headers if modified. if @from.modified? @headers["From"] = [ @from.to_s << (@from_tag ? ";tag=#{@from_tag}" : "") ] @from_was_modified = true