develooper Front page | perl.perl6.users | Postings from October 2017

Error Handling with IO::Socket.:Async::SLL

Thread Next
Martin Barth
October 16, 2017 10:23
Error Handling with IO::Socket.:Async::SLL
Message ID:
Hi there,

I need your help. I've been playing around with the code example from 
IO::Socket::Async::SSL and I am to stupid to get a propper error 
handling to work.

use v6;
use IO::Socket::Async::SSL;

react {
     my %ssl-config =
         certificate-file => 'cert.pem',
         private-key-file => 'key.pem';

     QUIT { say "this is quit outside whenever", $_.backtrace.full  }
     CATCH { say "this is catch outside whenever", $_.backtrace.full  }

     whenever IO::Socket::Async::SSL.listen('localhost', 4433, 
|%ssl-config) -> $conn {
         my $req = '';

         QUIT { say "this is quit inside whenever", $_.backtrace.full }
         CATCH { say "this is catch inside whenever", $_.backtrace.full }

         whenever $conn {
             $req ~= $_;
             if $req.contains("\r\n\r\n") {
                 say $req.lines[0];
                 try await $conn.print(
                     "HTTP/1.0 200 OK\r\nContent-type: text/html\r\n\r\n" ~
                     "<strong>Hello from a Perl 6 HTTP server</strong>\n");

what I am looking for is an example that dosen't shut down the server, 
or leaves the react block, for incomming http traffic or for ssl 
negotiation errors that might happen.



Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About