-
Notifications
You must be signed in to change notification settings - Fork 12
Make IO::Socket::SSL do the IO::Socket role #21
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
Conversation
@@ -11,7 +11,6 @@ sub v6-split($uri) { | |||
$host ?? ($host, $port) !! $uri; | |||
} | |||
|
|||
has Str $.encoding = 'utf8'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed because otherwise applying the role would die with Attribute '$!encoding' already exists in the class 'IO::Socket::SSL', but a role also wishes to compose it
. However, it should be safe to remove, since IO::Socket provides the same default: https://github.com/rakudo/rakudo/blob/master/src/core.c/IO/Socket.pm6#L3
lib/IO/Socket/SSL.pm6
Outdated
@@ -126,6 +125,10 @@ method print(Str $s) { | |||
$!ssl.write($s); | |||
} | |||
|
|||
method put(Str $s) { | |||
$!ssl.write($s ~ "\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use $.nl-out
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well spotted. I changed it to $!nl-out
, or do you think it's preferable to use the accessor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally try to avoid calling private accessors that come from outside the class (composed in from roles). It is fine (to me) for IO::Socket
to call $!nl-out
because it is declared in that class and thus the implementation details can be hidden. Using $.nl-out
outside of IO::Socket
is ok because it ensures it will use the public interface (maybe in the future there is no $!nl-out
, only method nl-out { ... }
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Amended
This makes it possible to assign an IO::Socket::SSL to a variable with an IO::Socket constraint. Without this, doing so would result in a hard to understand segmentation fault. In order for this work, the `put` method is also naively implemented.
This makes it possible to assign an IO::Socket::SSL to a variable
with an IO::Socket constraint. Without this, doing so would result
in a hard to understand segmentation fault.
In order for this work, the
put
method is also naively implemented.This fixes #20 and likely #3.