about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/yahns/proxy_http_response.rb8
-rw-r--r--lib/yahns/req_res.rb6
2 files changed, 10 insertions, 4 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)
diff --git a/lib/yahns/req_res.rb b/lib/yahns/req_res.rb
index 9bb8f35..041b908 100644
--- a/lib/yahns/req_res.rb
+++ b/lib/yahns/req_res.rb
@@ -42,7 +42,8 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
           # continue looping in middle "case @resbuf" loop
         when :wait_readable
           return rv # spurious wakeup
-        when nil then return c.proxy_err_response(502, self, nil)
+        when nil
+          return c.proxy_err_response(502, self, 'upstream EOF (headers)')
         end # NOT looping here
 
       when String # continue reading trickled response headers from upstream
@@ -50,7 +51,8 @@ class Yahns::ReqRes < Kgio::Socket # :nodoc:
         case rv = kgio_tryread(0x2000, buf)
         when String then res = req.headers(@hdr, resbuf << rv) and break
         when :wait_readable then return rv
-        when nil then return c.proxy_err_response(502, self, nil)
+        when nil
+          return c.proxy_err_response(502, self, 'upstream EOF (big headers)')
         end while true
         @resbuf = false