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
readonly
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
-
#input_buffering ⇒ Object
:lazy, true, false.
- #output_buffer_tmpdir ⇒ Object
-
#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) ⇒ Object
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
18 19 20 |
# File 'lib/yahns/http_context.rb', line 18 def app @app end |
#app_defaults ⇒ Object (readonly)
Returns the value of attribute app_defaults.
19 20 21 |
# File 'lib/yahns/http_context.rb', line 19 def app_defaults @app_defaults end |
#check_client_connection ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/yahns/http_context.rb', line 8 def check_client_connection @check_client_connection end |
#client_body_buffer_size ⇒ Object
Returns the value of attribute client_body_buffer_size.
9 10 11 |
# File 'lib/yahns/http_context.rb', line 9 def client_body_buffer_size @client_body_buffer_size end |
#client_header_buffer_size ⇒ Object
Returns the value of attribute client_header_buffer_size.
10 11 12 |
# File 'lib/yahns/http_context.rb', line 10 def client_header_buffer_size @client_header_buffer_size end |
#client_max_body_size ⇒ Object
Returns the value of attribute client_max_body_size.
11 12 13 |
# File 'lib/yahns/http_context.rb', line 11 def client_max_body_size @client_max_body_size end |
#client_timeout ⇒ Object
Returns the value of attribute client_timeout.
15 16 17 |
# File 'lib/yahns/http_context.rb', line 15 def client_timeout @client_timeout end |
#input_buffer_tmpdir ⇒ Object
91 92 93 |
# File 'lib/yahns/http_context.rb', line 91 def input_buffer_tmpdir @input_buffer_tmpdir || Dir.tmpdir end |
#input_buffering ⇒ Object
:lazy, true, false
12 13 14 |
# File 'lib/yahns/http_context.rb', line 12 def input_buffering @input_buffering end |
#output_buffer_tmpdir ⇒ Object
95 96 97 |
# File 'lib/yahns/http_context.rb', line 95 def output_buffer_tmpdir @output_buffer_tmpdir || Dir.tmpdir end |
#output_buffering ⇒ Object
true, false
13 14 15 |
# File 'lib/yahns/http_context.rb', line 13 def output_buffering @output_buffering end |
#persistent_connections ⇒ Object
true or false only
14 15 16 |
# File 'lib/yahns/http_context.rb', line 14 def persistent_connections @persistent_connections end |
#qegg ⇒ Object
Returns the value of attribute qegg.
16 17 18 |
# File 'lib/yahns/http_context.rb', line 16 def qegg @qegg end |
#queue ⇒ Object
set right before spawning acceptors
17 18 19 |
# File 'lib/yahns/http_context.rb', line 17 def queue @queue end |
Instance Method Details
#__wrap_app(app) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/yahns/http_context.rb', line 47 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
43 44 45 |
# File 'lib/yahns/http_context.rb', line 43 def after_fork_init @app = __wrap_app(@yahns_rack.app_after_fork) end |
#errors ⇒ Object
76 77 78 |
# File 'lib/yahns/http_context.rb', line 76 def errors @app_defaults["rack.errors"] end |
#errors=(dest) ⇒ Object
72 73 74 |
# File 'lib/yahns/http_context.rb', line 72 def errors=(dest) @app_defaults["rack.errors"] = dest end |
#http_ctx_init(yahns_rack) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/yahns/http_context.rb', line 23 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
64 65 66 |
# File 'lib/yahns/http_context.rb', line 64 def logger @app_defaults["rack.logger"] end |
#logger=(l) ⇒ Object
call this immediately after successful accept()/accept4()
60 61 62 |
# File 'lib/yahns/http_context.rb', line 60 def logger=(l) # cold @logger = @app_defaults["rack.logger"] = l end |
#mkinput(client, hs) ⇒ Object
68 69 70 |
# File 'lib/yahns/http_context.rb', line 68 def mkinput(client, hs) (@input_buffering ? Yahns::TeeInput : Yahns::StreamInput).new(client, hs) end |
#tmpio_for(len) ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'lib/yahns/http_context.rb', line 80 def tmpio_for(len) if len # Content-Length given len <= @client_body_buffer_size ? StringIO.new("") : Yahns::TmpIO.new(input_buffer_tmpdir) else # chunked, unknown length mbs = @client_max_body_size tmpdir = input_buffer_tmpdir mbs ? Yahns::CapInput.new(mbs, tmpdir) : Yahns::TmpIO.new(tmpdir) end end |