File: 15_multiline_header.t

package info (click to toggle)
libfurl-perl 3.14-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 660 kB
  • sloc: perl: 2,188; makefile: 5; sh: 1
file content (34 lines) | stat: -rw-r--r-- 862 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use Furl::HTTP;
use Test::TCP;
use Test::Requires qw(Plack::Request HTTP::Body), 'Plack';
use Plack::Loader;
use Test::More;

use Plack::Request;
use File::Temp;
use Fcntl qw/:seek/;

test_tcp(
    client => sub {
        my $port = shift;
        my $furl = Furl::HTTP->new();

        my ( undef, $status, $msg, $headers, $body ) =
          $furl->request( url => "http://127.0.0.1:$port/", headers => [ 'X-Foo' => "bar\015\012baz" ], method => 'GET' );
        is $status, 200;

        done_testing;
    },
    server => sub {
        my $port = shift;
        Plack::Loader->auto( port => $port )->run(
            sub {
                my $req = Plack::Request->new(shift);
                is $req->header('X-Foo'), "bar  baz";
                return [ 200, [ 'Content-Length' => 2 ], ['OK'] ];
            }
        );
    }
);