### ----------------------------------------------------
### -- HTTP::Server::Async
### -- Licenses: Artistic-2.0
### -- Authors: Tony O'Dell
### -- File: t/02-plugins.rakutest
### ----------------------------------------------------
use Test;

use lib 't/lib';
use starter;

plan 2;

my $s = srv;

my Str $timetest = time.Str;
$s.middleware: sub ($req, $res){
    $res.headers<XYZ> = 'ABC';    
    True
}

$s.handler: sub ($req,$res) {
    $res.headers<Connection> = 'close';
    $res.close($timetest);
}
$s.listen;

my $client = req;

$client.print("GET / HTTP/1.0\r\n\r\n");
my $data;
while $client.recv -> $str {
    $data ~= $str;
}
$client.close;

ok $data ~~ rx/^^ 'XYZ: ABC' $$/, 'Testing for XYZ Middleware Header';
ok $data ~~ rx/^^ "$timetest" $$/, "Testing for $timetest";

# vim: expandtab shiftwidth=4


