From 7013f9e3ca6c188fa14baba52e420437fd3ac2d6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 8 Jul 2018 07:35:58 +0000 Subject: http_client: clear backtrace on "wrong version number" in OpenSSL Errors which are the fault of the client should not generate backtraces which can lead to dinky servers running out-of-space. --- lib/yahns/http_client.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/yahns/http_client.rb b/lib/yahns/http_client.rb index d8154a4..fd97624 100644 --- a/lib/yahns/http_client.rb +++ b/lib/yahns/http_client.rb @@ -298,10 +298,18 @@ class Yahns::HttpClient < Kgio::Socket # :nodoc: when Unicorn::HttpParserError # try to tell the client they're bad 400 else + n = 500 + case e.class.to_s + when 'OpenSSL::SSL::SSLError' + if e.message.include?('wrong version number') + n = nil + e.set_backtrace([]) + end + end Yahns::Log.exception(@hs.env["rack.logger"], "app error", e) - 500 + n end - kgio_trywrite(err_response(code)) + kgio_trywrite(err_response(code)) if code rescue ensure shutdown rescue nil -- cgit v1.2.3-24-ge0c7