class Wukong::HttpRequest
Represents a generic HTTP request.
Public Instance Methods
best_ip_address()
click to toggle source
Return the “best” IP address from this request.
Will return the first IP address in the HTTP X-Forwarded-For chain if present, otherwise will return the IP address of the request itself.
@return [String]
# File lib/wukong-load/models/http_request.rb, line 52 def best_ip_address ip_string = headers['X-Forwarded-For'] return ip_address if ip_string.blank? ips = ip_string.split(/\s*,\s*/) ips.empty? ? ip_address : ips.first # client comes first, then proxies in order end
referer()
click to toggle source
Return the HTTP Referer of this request.
@return [String]
# File lib/wukong-load/models/http_request.rb, line 26 def referer headers['Referer'] end
Also aliased as: referrer
url()
click to toggle source
Return the URL of this request.
@return [String]
# File lib/wukong-load/models/http_request.rb, line 19 def url File.join(headers['Host'] || '', (path || '')) end
user_agent()
click to toggle source
Return the HTTP User-Agent of this request.
@return [String]
# File lib/wukong-load/models/http_request.rb, line 34 def user_agent headers['User-Agent'] end