Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement chomp: option for gets, readline, readlines, each_line #503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

casperisfine
Copy link

@casperisfine casperisfine commented Mar 16, 2022

It was added to IO methods in Ruby 2.4, but OpenSSL sockets don't have
them, so any code accepting SSL sockets can't make use of it.

Ref: ruby/ruby@a2144bd

cc @nobu since you implemented this in IO.

On another note, this led me to notice that SSLSocket#gets(nil) and SSLSocket#gets("") aren't supported either.

@nobu
Copy link
Member

nobu commented Mar 20, 2022

Seems fine.
The failure on mswin should be fixed by rebase.

test/openssl/test_ssl.rb Outdated Show resolved Hide resolved
@rhenium
Copy link
Member

rhenium commented Mar 21, 2022

Thanks for working on this! This is indeed overlooked and should be implemented.

Unlike IO#gets, OpenSSL::Buffering/OpenSSL::SSL::SSLSocket#gets accepts a Regexp as the eol parameter. Should this be made compatible with chomp option too? Or perhaps it can simply be documented as unsupported... I didn't know #gets took a Regexp at all.

On another note, this led me to notice that SSLSocket#gets(nil) and SSLSocket#gets("") aren't supported either.

I think that should be aligned with IO too, as these currently don't give any useful return value.

@casperisfine
Copy link
Author

Unlike IO#gets, OpenSSL::Buffering/OpenSSL::SSL::SSLSocket#gets accepts a Regexp as the eol parameter. Should this be made compatible with chomp option too?

um, so we'd need to chomp whatever the regexp matched? Seems tricky.

…line`

It was added to IO methods in Ruby 2.4, but OpenSSL sockets don't have
them, so any code accepting SSL sockets can't make use of it.

Ref: ruby/ruby@a2144bd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants