Class: QNA::Request
Overview
Constant Summary
QNA::RequestInfoClassMethods::MAX_PARAMETER_NAME_SIZE, QNA::RequestInfoClassMethods::MAX_PARAMETER_VALUE_SIZE, QNA::RequestInfoClassMethods::PARAMETER_RE
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
#redirect
#is, #on, #on_accept, #on_get, #on_options, #on_post, #on_query_param, #on_root, #on_upgrade, #route, #route_found, #routing_path, #stop_routing
#connection, #forwarded_for, #host, #method, #path, #protocol, #query, #query_string, #request_id, #scheme, #split_query_string, #upgrade_protocol, #uri
Constructor Details
#initialize(headers, adapter) ⇒ Request
Returns a new instance of Request.
19
20
21
22
|
# File 'lib/qna/request.rb', line 19
def initialize(, adapter)
@headers =
@adapter = adapter
end
|
Instance Attribute Details
#__next__ ⇒ Object
Returns the value of attribute __next__.
17
18
19
|
# File 'lib/qna/request.rb', line 17
def __next__
@__next__
end
|
#adapter ⇒ Object
Returns the value of attribute adapter.
16
17
18
|
# File 'lib/qna/request.rb', line 16
def adapter
@adapter
end
|
Returns the value of attribute headers.
16
17
18
|
# File 'lib/qna/request.rb', line 16
def
@headers
end
|
Instance Method Details
#buffer_body_chunk(chunk) ⇒ Object
24
25
26
27
|
# File 'lib/qna/request.rb', line 24
def buffer_body_chunk(chunk)
@buffered_body_chunks ||= []
@buffered_body_chunks << chunk
end
|
#complete!(keep_alive = nil) ⇒ Object
51
52
53
54
|
# File 'lib/qna/request.rb', line 51
def complete!(keep_alive = nil)
@message_complete = true
@keep_alive = keep_alive
end
|
#complete? ⇒ Boolean
56
57
58
|
# File 'lib/qna/request.rb', line 56
def complete?
@message_complete
end
|
#consume ⇒ Object
60
61
62
|
# File 'lib/qna/request.rb', line 60
def consume
@adapter.consume_request
end
|
#each_chunk ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/qna/request.rb', line 39
def each_chunk
if @buffered_body_chunks
while (chunk = @buffered_body_chunks.shift)
yield chunk
end
@buffered_body_chunks = nil
end
while !@message_complete && (chunk = @adapter.get_body_chunk)
yield chunk
end
end
|
#finish ⇒ Object
97
98
99
100
101
|
# File 'lib/qna/request.rb', line 97
def finish
({}) unless @headers_sent
@adapter.finish
end
|
103
104
105
|
# File 'lib/qna/request.rb', line 103
def
@headers_sent
end
|
#keep_alive? ⇒ Boolean
64
65
66
|
# File 'lib/qna/request.rb', line 64
def keep_alive?
@keep_alive
end
|
#next_chunk ⇒ Object
29
30
31
32
33
34
35
36
37
|
# File 'lib/qna/request.rb', line 29
def next_chunk
if @buffered_body_chunks
chunk = @buffered_body_chunks.shift
@buffered_body_chunks = nil if @buffered_body_chunks.empty?
return chunk
end
@message_complete ? nil : @adapter.get_body_chunk
end
|
#read ⇒ Object
Also known as:
body
68
69
70
71
72
73
74
75
|
# File 'lib/qna/request.rb', line 68
def read
buf = @buffered_body_chunks ? @buffered_body_chunks.join : nil
while (chunk = @adapter.get_body_chunk)
(buf ||= +'') << chunk
end
@buffered_body_chunks = nil
buf
end
|
#respond(body, headers = {}) ⇒ Object
78
79
80
81
|
# File 'lib/qna/request.rb', line 78
def respond(body, = {})
@adapter.respond(body, )
@headers_sent = true
end
|
#send_chunk(body, done: false) ⇒ Object
Also known as:
<<
90
91
92
93
94
|
# File 'lib/qna/request.rb', line 90
def send_chunk(body, done: false)
({}) unless @headers_sent
@adapter.send_chunk(body, done: done)
end
|
83
84
85
86
87
88
|
# File 'lib/qna/request.rb', line 83
def ( = {}, empty_response = false)
return if @headers_sent
@headers_sent = true
@adapter.(, empty_response: empty_response)
end
|