Skip to content

Commit

Permalink
Merge pull request #720 from kryzthov-stripe/kryzthov/readline-fix
Browse files Browse the repository at this point in the history
Excon::Socket.readline to use buffered reads
  • Loading branch information
geemus committed Jun 23, 2020
2 parents 9c60f23 + 251488a commit 13ac7b4
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions lib/excon/socket.rb
Expand Up @@ -60,18 +60,8 @@ def read(max_length = nil)
def readline
return legacy_readline if RUBY_VERSION.to_f <= 1.8_7
buffer = String.new
begin
buffer << @socket.read_nonblock(1) while buffer[-1] != "\n"
buffer
rescue *READ_RETRY_EXCEPTION_CLASSES
select_with_timeout(@socket, :read) && retry
rescue OpenSSL::SSL::SSLError => error
if error.message == 'read would block'
select_with_timeout(@socket, :read) && retry
else
raise(error)
end
end
buffer << read_nonblock(1) while buffer[-1] != "\n"
buffer
end

def legacy_readline
Expand Down

0 comments on commit 13ac7b4

Please sign in to comment.