Class: Qeweney::Request
Overview
Constant Summary
collapse
{}.freeze
Qeweney::RequestInfoClassMethods::MAX_PARAMETER_NAME_SIZE, Qeweney::RequestInfoClassMethods::MAX_PARAMETER_VALUE_SIZE, Qeweney::RequestInfoClassMethods::PARAMETER_RE
Qeweney::ResponseMethods::WEBSOCKET_GUID
Qeweney::RequestInfoMethods::COOKIE_RE, Qeweney::RequestInfoMethods::QUERY_KV_REGEXP, Qeweney::RequestInfoMethods::SEMICOLON
Instance Attribute Summary collapse
Instance Method Summary
collapse
parse_form_data, parse_multipart_form_data, parse_multipart_form_data_part, parse_multipart_form_data_part_headers, parse_urlencoded_form_data
#file_full_path, #redirect, #redirect_to_host, #redirect_to_https, #respond_with_static_file, #serve_file, #serve_io, #serve_io_deflate, #serve_io_gzip, #serve_rack, #upgrade, #upgrade_to_websocket, #validate_static_file_cache
#default, #enter_route, #is, #leave_route, #on, #on_accept, #on_get, #on_host, #on_options, #on_plain_http, #on_post, #on_query_param, #on_root, #on_upgrade, #on_websocket_upgrade, #reject, #route, #route_found, #route_part, #route_relative_path, #stop_routing
#accept_encoding, #connection, #cookies, #forwarded_for, #full_uri, #host, #method, #parse_cookies, #parse_query, #path, #protocol, #query, #query_string, #request_id, #rewrite!, #scheme, #upgrade_protocol, #uri, #websocket_version
Constructor Details
#initialize(headers, adapter) ⇒ Request
Returns a new instance of Request.
19
20
21
22
|
# File 'lib/qeweney/request.rb', line 19
def initialize(, adapter)
@headers =
@adapter = adapter
end
|
Instance Attribute Details
#adapter ⇒ Object
Returns the value of attribute adapter.
17
18
19
|
# File 'lib/qeweney/request.rb', line 17
def adapter
@adapter
end
|
Returns the value of attribute headers.
17
18
19
|
# File 'lib/qeweney/request.rb', line 17
def
@headers
end
|
Instance Method Details
#buffer_body_chunk(chunk) ⇒ Object
24
25
26
27
|
# File 'lib/qeweney/request.rb', line 24
def buffer_body_chunk(chunk)
@buffered_body_chunks ||= []
@buffered_body_chunks << chunk
end
|
#complete? ⇒ Boolean
67
68
69
|
# File 'lib/qeweney/request.rb', line 67
def complete?
@adapter.complete?(self)
end
|
#each_chunk ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/qeweney/request.rb', line 41
def each_chunk
if @buffered_body_chunks
while (chunk = @buffered_body_chunks.shift)
yield chunk
end
@buffered_body_chunks = nil
end
while (chunk = @adapter.get_body_chunk(self))
yield chunk
end
end
|
#finish ⇒ Object
92
93
94
95
96
|
# File 'lib/qeweney/request.rb', line 92
def finish
({}) unless @headers_sent
@adapter.finish(self)
end
|
98
99
100
|
# File 'lib/qeweney/request.rb', line 98
def
@headers_sent
end
|
#next_chunk(buffered_only = false) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/qeweney/request.rb', line 29
def next_chunk(buffered_only = false)
if @buffered_body_chunks
chunk = @buffered_body_chunks.shift
@buffered_body_chunks = nil if @buffered_body_chunks.empty?
return chunk
elsif buffered_only
return nil
end
@adapter.get_body_chunk(self, buffered_only)
end
|
#read ⇒ Object
Also known as:
body
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/qeweney/request.rb', line 53
def read
if @buffered_body_chunks
body = @buffered_body_chunks.join
if !complete?
rest = @adapter.get_body(self)
body << rest if rest
end
@buffered_body_chunks = nil
return body
end
@adapter.get_body(self)
end
|
#respond(body, headers = EMPTY_HEADERS) ⇒ Object
73
74
75
76
|
# File 'lib/qeweney/request.rb', line 73
def respond(body, = EMPTY_HEADERS)
@adapter.respond(self, body, )
@headers_sent = true
end
|
#rx_incr(count) ⇒ Object
102
103
104
|
# File 'lib/qeweney/request.rb', line 102
def rx_incr(count)
[':rx'] ? [':rx'] += count : [':rx'] = count
end
|
#send_chunk(body, done: false) ⇒ Object
Also known as:
<<
85
86
87
88
89
|
# File 'lib/qeweney/request.rb', line 85
def send_chunk(body, done: false)
({}) unless @headers_sent
@adapter.send_chunk(self, body, done: done)
end
|
78
79
80
81
82
83
|
# File 'lib/qeweney/request.rb', line 78
def ( = EMPTY_HEADERS, empty_response = false)
return if @headers_sent
@headers_sent = true
@adapter.(self, , empty_response: empty_response)
end
|
#total_transfer ⇒ Object
114
115
116
|
# File 'lib/qeweney/request.rb', line 114
def total_transfer
([':rx'] || 0) + ([':tx'] || 0)
end
|
#transfer_counts ⇒ Object
110
111
112
|
# File 'lib/qeweney/request.rb', line 110
def transfer_counts
[[':rx'], [':tx']]
end
|
#tx_incr(count) ⇒ Object
106
107
108
|
# File 'lib/qeweney/request.rb', line 106
def tx_incr(count)
[':tx'] ? [':tx'] += count : [':tx'] = count
end
|