lib/oversip/sip/request.rb in oversip-1.1.2 vs lib/oversip/sip/request.rb in oversip-1.2.0
- old
+ new
@@ -1,19 +1,21 @@
module OverSIP::SIP
class Request < Message
+ include ::OverSIP::SIP::Core
+
SECURE_TRANSPORTS = { :tls=>true, :wss=>true }
attr_accessor :server_transaction
attr_reader :ruri
attr_reader :new_max_forwards
attr_accessor :antiloop_id
attr_accessor :route_outbound_flow_token
-
attr_writer :outgoing_outbound_requested, :incoming_outbound_requested
attr_accessor :proxied # If true it means that this request has been already proxied.
+ attr_reader :from_was_modified, :to_was_modified # Set to true if the From / To has been modified prior to routing the request.
# Used for internal purposes when doing proxy and adding the first Record-Route
# or Path.
attr_accessor :in_rr
@@ -111,9 +113,22 @@
end
def to_s
msg = "#{@sip_method.to_s} #{self.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
+ end
+ if @to.modified?
+ @headers["To"] = [ @to.to_s << (@to_tag ? ";tag=#{@to_tag}" : "") ]
+ @to_was_modified = true
+ end
+ if @contact and @contact.modified?
+ @headers["Contact"] = [ @contact.to_s << (@contact_params ? @contact_params : "") ]
+ end
@headers.each do |key, values|
values.each do |value|
msg << key << ": #{value}\r\n"
end