From 075fa4b4dac9f18a476b31c7ea8639a361a038e3 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 7 Feb 2021 01:52:16 +1300 Subject: Remove MYMETA.* from MANIFEST Fixes Bug #111703: Per: --- MANIFEST | 2 -- 1 file changed, 2 deletions(-) diff --git a/MANIFEST b/MANIFEST index 2fa1e0d..0cb897e 100644 --- a/MANIFEST +++ b/MANIFEST @@ -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 -- cgit v1.2.3 From 2bea92342d3c58ba197c00fff237f0e202f671c6 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 7 Feb 2021 01:54:46 +1300 Subject: Use CRLF line endings in GET request The HTTP::Request->as_string() method uses \n as an end-of-line token default. Apache HTTPD and Lua's http_server don't tolerate these as line endings, and throw 400 errors promptly. Providing CRLF explicitly as the end-of-line character makes the request palatable to these servers, and probably others with the same strictness. --- lib/POE/Component/Client/WebSocket.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/POE/Component/Client/WebSocket.pm b/lib/POE/Component/Client/WebSocket.pm index a78ba2e..e428672 100644 --- a/lib/POE/Component/Client/WebSocket.pm +++ b/lib/POE/Component/Client/WebSocket.pm @@ -467,7 +467,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; -- cgit v1.2.3 From 6ba517dfd0d85efb30250dcb2bc7e59af1859ffa Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 7 Feb 2021 02:01:37 +1300 Subject: Switch protocol for Origin header based on TLS If the websocket server is running over TLS, it's likely that the origin server matching it should be specified as HTTPS. --- lib/POE/Component/Client/WebSocket.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/POE/Component/Client/WebSocket.pm b/lib/POE/Component/Client/WebSocket.pm index e428672..8f5ff3c 100644 --- a/lib/POE/Component/Client/WebSocket.pm +++ b/lib/POE/Component/Client/WebSocket.pm @@ -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 => { -- cgit v1.2.3 From a2a6b489e5bceda1dda10d90f7cee62f9ff62852 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 7 Feb 2021 02:03:41 +1300 Subject: Add SNI parameter to POE::Filter::SSL --- lib/POE/Component/Client/WebSocket.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/POE/Component/Client/WebSocket.pm b/lib/POE/Component/Client/WebSocket.pm index 8f5ff3c..642ac64 100644 --- a/lib/POE/Component/Client/WebSocket.pm +++ b/lib/POE/Component/Client/WebSocket.pm @@ -433,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} ]); -- cgit v1.2.3 From 96e5706f790b5a93adfa4c7e841bc67f7af613da Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Sun, 7 Feb 2021 02:04:26 +1300 Subject: Preserve URI path from original request --- lib/POE/Component/Client/WebSocket.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/POE/Component/Client/WebSocket.pm b/lib/POE/Component/Client/WebSocket.pm index 642ac64..c2e2ccd 100644 --- a/lib/POE/Component/Client/WebSocket.pm +++ b/lib/POE/Component/Client/WebSocket.pm @@ -457,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', -- cgit v1.2.3