This will allow us to add extra options at the response
layer without taking up extra env hash keys.
---
lib/yahns/proxy_http_response.rb | 2 +-
lib/yahns/proxy_pass.rb | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index 284a3c6..c7a9447 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -71,7 +71,7 @@ def proxy_res_headers(res)
flags = MSG_DONTWAIT
alive = @hs.next? && self.class.persistent_connections
term = false
- response_headers = env['yahns.proxy_pass.response_headers']
+ response_headers = env['yahns.proxy_pass'].response_headers
res = "HTTP/1.1 #{msg ? %Q(#{code} #{msg}) : status}\r\n".dup
headers.each do |key,value| # n.b.: headers is an Array of 2-element Arrays
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index a30089d..ed37da5 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -10,6 +10,8 @@
require_relative 'req_res'
class Yahns::ProxyPass # :nodoc:
+ attr_reader :proxy_buffering, :response_headers
+
def initialize(dest, opts = {})
case dest
when %r{\Aunix:([^:]+)(?::(/.*))?\z}
@@ -23,6 +25,8 @@ def initialize(dest, opts = {})
raise ArgumentError, "destination must be an HTTP URL or unix: path"
end
@response_headers = opts[:response_headers] || {}
+ @proxy_buffering = opts[:proxy_buffering]
+ @proxy_buffering = true if @proxy_buffering.nil? # allow false
# It's wrong to send the backend Server tag through. Let users say
# { "Server => "yahns" } if they want to advertise for us, but don't
@@ -85,7 +89,7 @@ def call(env)
ctype = env["CONTENT_TYPE"] and req << "Content-Type: #{ctype}\r\n"
clen = env["CONTENT_LENGTH"] and req << "Content-Length: #{clen}\r\n"
input = chunked || (clen && clen.to_i > 0) ? env['rack.input'] : nil
- env['yahns.proxy_pass.response_headers'] = @response_headers
+ env['yahns.proxy_pass'] = self
# finally, prepare to emit the headers
rr.req_start(c, req << "\r\n".freeze, input, chunked)
--
EW
--
unsubscribe: [email protected]
archive: https://yhbt.net/yahns-public/