example/upgrade_client.rb in http-2-0.9.1 vs example/upgrade_client.rb in http-2-0.10.0

- old
+ new

@@ -32,20 +32,20 @@ puts "Received frame: #{frame.inspect}" end # upgrader module class UpgradeHandler - UPGRADE_REQUEST = <<-RESP.freeze -GET %s HTTP/1.1 -Connection: Upgrade, HTTP2-Settings -HTTP2-Settings: #{HTTP2::Client.settings_header(settings_max_concurrent_streams: 100)} -Upgrade: h2c -Host: %s -User-Agent: http-2 upgrade -Accept: */* + UPGRADE_REQUEST = <<-RESP.strip_heredoc.freeze + GET %s HTTP/1.1 + Connection: Upgrade, HTTP2-Settings + HTTP2-Settings: #{HTTP2::Client.settings_header(settings_max_concurrent_streams: 100)} + Upgrade: h2c + Host: %s + User-Agent: http-2 upgrade + Accept: */* -RESP + RESP attr_reader :complete, :parsing def initialize(conn, sock) @conn = conn @sock = sock @@ -71,13 +71,13 @@ def complete! @complete = true end - def on_headers_complete(h) - @headers.merge!(h) - puts "received headers: #{h}" + def on_headers_complete(headers) + @headers.merge!(headers) + puts "received headers: #{headers}" end def on_body(chunk) puts "received chunk: #{chunk}" @body << chunk @@ -142,11 +142,10 @@ elsif uh.parsing && !uh.complete uh << data elsif uh.complete conn << data end - - rescue => e + rescue StandardError => e puts "#{e.class} exception: #{e.message} - closing socket." e.backtrace.each { |l| puts "\t" + l } conn.close sock.close end