From b7b99f6c1f476922cba4973efc0ea90fabf2fc56 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Thu, 20 Jun 2019 11:12:21 +0900 Subject: [PATCH 1/2] support 2.3 on CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 34bafb0..d10a2ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ cache: bundler matrix: include: + - rvm: 2.3 - rvm: 2.4 - rvm: 2.5 - rvm: 2.6 From 3f598e97cc3bc3a2e4c68229348ee04498d66150 Mon Sep 17 00:00:00 2001 From: Yuta Iwama Date: Thu, 20 Jun 2019 15:19:32 +0900 Subject: [PATCH 2/2] monkey patch gets to match with 2.4 or later get's interface the following implementation is the best, but it will block and never return. I don't know why it's occured... ``` class IO def gets(*args, chomp: false) chomp ? super(*args).chomp : super(*args) end end ``` --- spec/protocol/http1/connection_context.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spec/protocol/http1/connection_context.rb b/spec/protocol/http1/connection_context.rb index 2e8bbd4..dbf372f 100644 --- a/spec/protocol/http1/connection_context.rb +++ b/spec/protocol/http1/connection_context.rb @@ -23,8 +23,24 @@ require 'socket' RSpec.shared_context Protocol::HTTP1::Connection do - let(:sockets) {Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM)} - + let(:sockets) { + r, w = Socket.pair(Socket::PF_UNIX, Socket::SOCK_STREAM) + # https://github.com/socketry/protocol-http1/pull/1#discussion_r295598266 + # https://docs.ruby-lang.org/en/2.3.0/IO.html#method-i-gets + # https://docs.ruby-lang.org/en/2.5.0/IO.html#method-i-gets + if !($stdin.gets(nil, 0, chomp: true) rescue nil) + def r.gets(*args, chomp: false) + chomp ? super(*args).chomp : super(*args) + end + + def w.gets(*args, chomp: false) + chomp ? super(*args).chomp : super(*args) + end + end + + [r, w] + } + let(:client) {Protocol::HTTP1::Connection.new(sockets.first)} let(:server) {Protocol::HTTP1::Connection.new(sockets.last)} end