diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2021-02-07 02:10:22 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2021-02-07 02:10:22 +1300 |
commit | ae8826efab92e4073c7ac8692a374eba94aec056 (patch) | |
tree | e039eaa199a7845a93f74f780637bfca470b75a9 | |
parent | Commit v0.27 as found on CPAN (diff) | |
parent | Preserve URI path from original request (diff) | |
download | POE-Component-Client-WebSocket-ae8826efab92e4073c7ac8692a374eba94aec056.tar.gz POE-Component-Client-WebSocket-ae8826efab92e4073c7ac8692a374eba94aec056.zip |
* release/v0.28:
Preserve URI path from original request
Add SNI parameter to POE::Filter::SSL
Switch protocol for Origin header based on TLS
Use CRLF line endings in GET request
Remove MYMETA.* from MANIFEST
-rw-r--r-- | Changes | 6 | ||||
-rw-r--r-- | MANIFEST | 2 | ||||
-rw-r--r-- | lib/POE/Component/Client/WebSocket.pm | 16 |
3 files changed, 17 insertions, 7 deletions
@@ -1,5 +1,11 @@ Revision history for POE-Component-Client-WebSocket +0.28 01/05/2021 13:07 UTC + Include hostname in SNI + Correct ignored path in URL + Use \r\n line endings in HTTP requests + Choose HTTPS protocol for Origin header + 0.27 01/05/2017 07:49 Connected missing socket_death handler (alerts of upstream disconnected) @@ -7,8 +7,6 @@ makeNotes MANIFEST This list of files MANIFEST.bak MANIFEST.SKIP -MYMETA.json -MYMETA.yml README t/00-load.t t/manifest.t diff --git a/lib/POE/Component/Client/WebSocket.pm b/lib/POE/Component/Client/WebSocket.pm index a78ba2e..2573b74 100644 --- a/lib/POE/Component/Client/WebSocket.pm +++ b/lib/POE/Component/Client/WebSocket.pm @@ -5,7 +5,7 @@ use strict; use warnings; use vars qw($VERSION); -$VERSION = '0.27'; +$VERSION = '0.28'; use Carp qw(carp croak); use Errno qw(ETIMEDOUT ECONNRESET); @@ -132,6 +132,9 @@ sub new { my $key = ""; for (1..16) { $key .= int(rand(9)) } + my $origin = (uc $scheme eq 'WSS' ? 'https' : 'http') + . "://$host"; + $self->{session} = POE::Session->create( package_states => [ $self => { @@ -167,7 +170,7 @@ sub new { port => $port, }, req => { - 'origin' => 'http://'.$host, + 'origin' => $origin, 'sec-websocket-key' => encode_base64($key), }, _state => { @@ -430,7 +433,10 @@ sub _socket_birth { my ($kernel, $socket, $sockid, $heap) = @_[KERNEL, ARG0, ARG3, HEAP]; if ( uc($heap->{uri}->{scheme}) eq 'WSS' ) { - $heap->{_state}->{sslfilter} = POE::Filter::SSL->new(client=>1); + $heap->{_state}->{sslfilter} = POE::Filter::SSL->new( + client => 1, + sni => $heap->{uri}->{host}, + ); $heap->{filters}->{output} = POE::Filter::Stackable->new(Filters => [ $heap->{_state}->{sslfilter} ]); $heap->{filters}->{input} = POE::Filter::Stackable->new(Filters => [ $heap->{_state}->{sslfilter} ]); @@ -451,7 +457,7 @@ sub _socket_birth { ErrorEvent => 'socket_death', ); - my $request = HTTP::Request->new(GET => '/'); + my $request = HTTP::Request->new(GET => $heap->{uri}->{path}); $request->protocol('HTTP/1.1'); $request->header( Upgrade => 'WebSocket', @@ -467,7 +473,7 @@ sub _socket_birth { $heap->{httpresp} = 1; # Send the request to the server - $heap->{wheel}->put($request->as_string()); + $heap->{wheel}->put($request->as_string("\r\n")); # Incase we want to investigate what we sent later. $heap->{_state}->{req} = $request; |