module Qeweney::RequestInfoMethods
Constants
- COOKIE_RE
- QUERY_KV_REGEXP
- SEMICOLON
Public Instance Methods
accept_encoding()
click to toggle source
TODO: should return encodings in client's order of preference (and take into account q weights)
# File lib/qeweney/request_info.rb, line 79 def accept_encoding encoding = @headers['accept-encoding'] return [] unless encoding encoding.split(',').map { |i| i.strip } end
connection()
click to toggle source
# File lib/qeweney/request_info.rb, line 13 def connection @headers['connection'] end
forwarded_for()
click to toggle source
# File lib/qeweney/request_info.rb, line 73 def forwarded_for @headers['x-forwarded-for'] end
full_uri()
click to toggle source
# File lib/qeweney/request_info.rb, line 41 def full_uri @full_uri = "#{scheme}://#{host}#{uri}" end
host()
click to toggle source
# File lib/qeweney/request_info.rb, line 8 def host @headers['host'] || @headers[':authority'] end
Also aliased as: authority
method()
click to toggle source
# File lib/qeweney/request_info.rb, line 29 def method @method ||= @headers[':method'].downcase end
parse_query(query)
click to toggle source
# File lib/qeweney/request_info.rb, line 61 def parse_query(query) query.split('&').each_with_object({}) do |kv, h| k, v = kv.match(QUERY_KV_REGEXP)[1..2] # k, v = kv.split('=') h[k.to_sym] = v ? URI.decode_www_form_component(v) : true end end
path()
click to toggle source
# File lib/qeweney/request_info.rb, line 45 def path @path ||= uri.path end
protocol()
click to toggle source
# File lib/qeweney/request_info.rb, line 25 def protocol @protocol ||= @adapter.protocol end
query()
click to toggle source
# File lib/qeweney/request_info.rb, line 53 def query return @query if @query @query = (q = uri.query) ? parse_query(q) : {} end
query_string()
click to toggle source
# File lib/qeweney/request_info.rb, line 49 def query_string @query_string ||= uri.query end
request_id()
click to toggle source
# File lib/qeweney/request_info.rb, line 69 def request_id @headers['x-request-id'] end
scheme()
click to toggle source
# File lib/qeweney/request_info.rb, line 33 def scheme @scheme ||= @headers[':scheme'] end
upgrade_protocol()
click to toggle source
# File lib/qeweney/request_info.rb, line 17 def upgrade_protocol connection == 'upgrade' && @headers['upgrade']&.downcase end
uri()
click to toggle source
# File lib/qeweney/request_info.rb, line 37 def uri @uri ||= URI.parse(@headers[':path'] || '') end
websocket_version()
click to toggle source
# File lib/qeweney/request_info.rb, line 21 def websocket_version headers['sec-websocket-version'].to_i end