From a3e3ab48a5a73e7d55bfcb271e5f2a1b666a4f8c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 1 Jun 2016 23:53:33 +0000 Subject: proxy_pass: pass entire object to proxy_http_response This will allow us to add extra options at the response layer without taking up extra env hash keys. --- lib/yahns/proxy_pass.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/yahns/proxy_pass.rb') 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 'proxy_http_response' 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 @@ class Yahns::ProxyPass # :nodoc: 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 @@ class Yahns::ProxyPass # :nodoc: 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) -- cgit v1.2.3-24-ge0c7