Module: Yahns::HttpContext
- Defined in:
- lib/yahns/http_context.rb
Overview
subclasses of Yahns::HttpClient will class extend this
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#app_defaults ⇒ Object
Returns the value of attribute app_defaults.
-
#check_client_connection ⇒ Object
:nodoc:.
-
#client_body_buffer_size ⇒ Object
Returns the value of attribute client_body_buffer_size.
-
#client_header_buffer_size ⇒ Object
Returns the value of attribute client_header_buffer_size.
-
#client_max_body_size ⇒ Object
Returns the value of attribute client_max_body_size.
-
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
-
#input_buffer_tmpdir ⇒ Object
writeonly
Sets the attribute input_buffer_tmpdir.
-
#input_buffering ⇒ Object
:lazy, true, false.
-
#output_buffer_tmpdir ⇒ Object
Returns the value of attribute output_buffer_tmpdir.
-
#output_buffering ⇒ Object
true, false.
-
#persistent_connections ⇒ Object
true or false only.
-
#qegg ⇒ Object
Returns the value of attribute qegg.
-
#queue ⇒ Object
set right before spawning acceptors.
Instance Method Summary collapse
- #__wrap_app(app) ⇒ Object
-
#after_fork_init ⇒ Object
call this after forking.
- #errors ⇒ Object
- #errors=(dest) ⇒ Object
- #http_ctx_init(yahns_rack) ⇒ Object
- #logger ⇒ Object
-
#logger=(l) ⇒ Object
call this immediately after successful accept()/accept4().
- #mkinput(client, hs) ⇒ Object
- #tmpio_for(len, env) ⇒ Object
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
19 20 21 |
# File 'lib/yahns/http_context.rb', line 19 def app @app end |
#app_defaults ⇒ Object
Returns the value of attribute app_defaults.
20 21 22 |
# File 'lib/yahns/http_context.rb', line 20 def app_defaults @app_defaults end |
#check_client_connection ⇒ Object
:nodoc:
9 10 11 |
# File 'lib/yahns/http_context.rb', line 9 def check_client_connection @check_client_connection end |
#client_body_buffer_size ⇒ Object
Returns the value of attribute client_body_buffer_size.
10 11 12 |
# File 'lib/yahns/http_context.rb', line 10 def client_body_buffer_size @client_body_buffer_size end |
#client_header_buffer_size ⇒ Object
Returns the value of attribute client_header_buffer_size.
11 12 13 |
# File 'lib/yahns/http_context.rb', line 11 def client_header_buffer_size @client_header_buffer_size end |
#client_max_body_size ⇒ Object
Returns the value of attribute client_max_body_size.
12 13 14 |
# File 'lib/yahns/http_context.rb', line 12 def client_max_body_size @client_max_body_size end |
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
16 17 18 |
# File 'lib/yahns/http_context.rb', line 16 def client_timeout @client_timeout end |
#input_buffer_tmpdir=(value) ⇒ Object (writeonly)
Sets the attribute input_buffer_tmpdir
21 22 23 |
# File 'lib/yahns/http_context.rb', line 21 def input_buffer_tmpdir=(value) @input_buffer_tmpdir = value end |
#input_buffering ⇒ Object
:lazy, true, false
13 14 15 |
# File 'lib/yahns/http_context.rb', line 13 def input_buffering @input_buffering end |
#output_buffer_tmpdir ⇒ Object
Returns the value of attribute output_buffer_tmpdir.
22 23 24 |
# File 'lib/yahns/http_context.rb', line 22 def output_buffer_tmpdir @output_buffer_tmpdir end |
#output_buffering ⇒ Object
true, false
14 15 16 |
# File 'lib/yahns/http_context.rb', line 14 def output_buffering @output_buffering end |
#persistent_connections ⇒ Object
true or false only
15 16 17 |
# File 'lib/yahns/http_context.rb', line 15 def persistent_connections @persistent_connections end |
#qegg ⇒ Object
Returns the value of attribute qegg.
17 18 19 |
# File 'lib/yahns/http_context.rb', line 17 def qegg @qegg end |
#queue ⇒ Object
set right before spawning acceptors
18 19 20 |
# File 'lib/yahns/http_context.rb', line 18 def queue @queue end |
Instance Method Details
#__wrap_app(app) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/yahns/http_context.rb', line 48 def __wrap_app(app) # input_buffering == false is handled in http_client return app if @client_max_body_size.nil? require_relative 'cap_input' return app if @input_buffering == true # @input_buffering == false/:lazy require_relative 'max_body' Yahns::MaxBody.new(app, @client_max_body_size) end |
#after_fork_init ⇒ Object
call this after forking
44 45 46 |
# File 'lib/yahns/http_context.rb', line 44 def after_fork_init @app = __wrap_app(@yahns_rack.app_after_fork) end |
#errors ⇒ Object
77 78 79 |
# File 'lib/yahns/http_context.rb', line 77 def errors @app_defaults["rack.errors"] end |
#errors=(dest) ⇒ Object
73 74 75 |
# File 'lib/yahns/http_context.rb', line 73 def errors=(dest) @app_defaults["rack.errors"] = dest end |
#http_ctx_init(yahns_rack) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yahns/http_context.rb', line 24 def http_ctx_init(yahns_rack) @yahns_rack = yahns_rack @app_defaults = yahns_rack.app_defaults @check_client_connection = false @client_body_buffer_size = 8 * 1024 @client_header_buffer_size = 4000 @client_max_body_size = 1024 * 1024 # nil => infinity @input_buffering = true @output_buffering = true @persistent_connections = true @client_timeout = 15 @qegg = nil @queue = nil # Dir.tmpdir can change while running, so leave these as nil @input_buffer_tmpdir = nil @output_buffer_tmpdir = nil end |
#logger ⇒ Object
65 66 67 |
# File 'lib/yahns/http_context.rb', line 65 def logger @app_defaults["rack.logger"] end |
#logger=(l) ⇒ Object
call this immediately after successful accept()/accept4()
61 62 63 |
# File 'lib/yahns/http_context.rb', line 61 def logger=(l) # cold @logger = @app_defaults["rack.logger"] = l end |
#mkinput(client, hs) ⇒ Object
69 70 71 |
# File 'lib/yahns/http_context.rb', line 69 def mkinput(client, hs) (@input_buffering ? Yahns::TeeInput : Yahns::StreamInput).new(client, hs) end |
#tmpio_for(len, env) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/yahns/http_context.rb', line 81 def tmpio_for(len, env) # short requests are most common if len && len <= @client_body_buffer_size; # Can't use binmode, yet: https://bugs.ruby-lang.org/issues/11945 tmp = StringIO.new(''.dup) else # too big or chunked, unknown length tmp = @input_buffer_tmpdir mbs = @client_max_body_size tmp = mbs ? Yahns::CapInput.new(mbs, tmp) : Yahns::TmpIO.new(tmp) (env['rack.tempfiles'] ||= []) << tmp end tmp end |