about summary refs log tree commit homepage
path: root/lib/yahns/proxy_http_response.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-07 04:07:19 +0000
committerEric Wong <e@80x24.org>2016-06-07 07:18:34 +0000
commit31a7777d0c646796e9a344c54f64269c51801fb6 (patch)
treea2920109a21846fe254980b7933b12b299493895 /lib/yahns/proxy_http_response.rb
parent46614f480a8b8f54ee32e670306c554d016bf3df (diff)
downloadyahns-31a7777d0c646796e9a344c54f64269c51801fb6.tar.gz
This should make it easier to figure out where certain
errors are coming from and perhaps fix problems with
upstreams, too.

This helped me track down the problem causing public-inbox WWW
component running under Perl v5.20.2 on my Debian jessie system
to break and drop connections going through
Plack::Middleware::Deflater with gzip:

  https://public-inbox.org/meta/20160607071401.29325-1-e@80x24.org/

Perl 5.14.2 on Debian wheezy did not detect this problem :x
Diffstat (limited to 'lib/yahns/proxy_http_response.rb')
-rw-r--r--lib/yahns/proxy_http_response.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/yahns/proxy_http_response.rb b/lib/yahns/proxy_http_response.rb
index 8de5b4f..9867da2 100644
--- a/lib/yahns/proxy_http_response.rb
+++ b/lib/yahns/proxy_http_response.rb
@@ -53,6 +53,8 @@ module Yahns::HttpResponse # :nodoc:
       logger.error('premature upstream EOF')
     when Kcar::ParserError
       logger.error("upstream response error: #{exc.message}")
+    when String
+      logger.error(exc)
     else
       Yahns::Log.exception(logger, 'upstream error', exc)
     end
@@ -167,7 +169,9 @@ module Yahns::HttpResponse # :nodoc:
       return proxy_unbuffer(wbuf) if Yahns::WbufLite === wbuf
     when nil # EOF
       # HTTP/1.1 upstream, unexpected premature EOF:
-      return proxy_err_response(nil, req_res, nil) if len || chunk
+      msg = "upstream EOF (#{len} bytes left)" if len
+      msg = 'upstream EOF (chunk)' if chunk
+      return proxy_err_response(nil, req_res, msg) if msg
 
       # HTTP/1.0 upstream:
       wbuf = proxy_write(wbuf, "0\r\n\r\n".freeze, req_res) if alive
@@ -198,7 +202,7 @@ module Yahns::HttpResponse # :nodoc:
       when :wait_readable
         return wait_on_upstream(req_res)
       when nil # premature EOF
-        return proxy_err_response(nil, req_res, nil)
+        return proxy_err_response(nil, req_res, 'upstream EOF (trailers)')
       end # no loop here
     end
     wbuf = proxy_write(wbuf, trailer_out(tlr), req_res)