module Strelka::HTTPRequest::CORS
The mixin that adds methods to Strelka::HTTPRequest
for Cross-Origin Resource Sharing (CORS
).
Public Instance Methods
cross_origin?()
click to toggle source
Returns true
if the request contains an Origin header whose URI has a host that's different than its Host: header.
# File lib/strelka/httprequest/cors.rb, line 37 def cross_origin? return self.origin && self.headers.host != self.origin.host end
Also aliased as: is_cross_origin?
origin()
click to toggle source
Return the URI in the Origin header (if the request has one) as a URI object. If the request doesn't have an Origin: header, returns nil.
# File lib/strelka/httprequest/cors.rb, line 25 def origin unless @origin origin_uri = self.headers.origin or return nil @origin = URI( origin_uri ) end return @origin end
preflight?()
click to toggle source
Returns true
if the receiver is a CORS
preflight request.
# File lib/strelka/httprequest/cors.rb, line 44 def preflight? return self.origin && self.verb == :OPTIONS && self.header.access_control_request_method end
Also aliased as: is_preflight?
Protected Instance Methods
initialize( * )
click to toggle source
Add some instance variables to the request object.
Calls superclass method
# File lib/strelka/httprequest/cors.rb, line 12 def initialize( * ) # :notnew: super @origin = nil end