File: 29_completion_slash.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 (135 lines) | stat: -rw-r--r-- 3,661 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
use strict;
use warnings;
use Furl::HTTP;
use Test::TCP;
use Test::More;
use FindBin;
use lib "$FindBin::Bin/../..";
use t::HTTPServer;

my $server = sub {
    my $port = shift;
    t::HTTPServer->new(port => $port)->run(sub {
        my $env = shift;
        return [
            200,
            [ 'Content-Length' => length($env->{REQUEST_URI}) ],
            [ $env->{REQUEST_URI} ],
        ];
    });
};

note '/foo => /foo';
test_tcp(
    server => $server,
    client => sub {
        my $port = shift;
        my $furl = Furl::HTTP->new(bufsize => 10, timeout => 3);

        do {
            my (undef, $code, $msg, $headers, $content) = $furl->request(
                port       => $port,
                path_query => '/foo',
                host       => '127.0.0.1',
            );
            is $code, 200, "code";
            is $msg, "OK" , "msg";
            is $content, "/foo", "return path query";
        };

        do {
            my $path_query = '/foo';
            my ( undef, $code, $msg, $headers, $content ) = $furl->request(
                url    => "http://127.0.0.1:$port$path_query",
                method => 'GET',
            );
            is $code, 200, 'code';
            is $msg, 'OK', 'msg';
            is $content, '/foo';
        };
    },
);

note 'foo => /foo';
test_tcp(
    server => $server,
    client => sub {
        my $port = shift;
        my $furl = Furl::HTTP->new(bufsize => 10, timeout => 3);

        do {
            my (undef, $code, $msg, $headers, $content) = $furl->request(
                port       => $port,
                path_query => 'foo',
                host       => '127.0.0.1',
            );
            is $code, 200, 'code';
            is $msg, 'OK' , 'msg';
            is $content, '/foo', 'return path query';
        };
    },
);

note '/?foo=bar => /?foo=bar';
test_tcp(
    server => $server,
    client => sub {
        my $port = shift;
        my $furl = Furl::HTTP->new(bufsize => 10, timeout => 3);

        do {
            my (undef, $code, $msg, $headers, $content) = $furl->request(
                port       => $port,
                path_query => '/?foo=bar',
                host       => '127.0.0.1',
            );
            is $code, 200, 'code';
            is $msg, 'OK' , 'msg';
            is $content, '/?foo=bar', 'return path query';
        };

        do {
            my $path_query = '/?foo=bar';
            my ( undef, $code, $msg, $headers, $content ) = $furl->request(
                url    => "http://127.0.0.1:$port$path_query",
                method => 'GET',
            );
            is $code, 200, 'code';
            is $msg, 'OK', 'msg';
            is $content, '/?foo=bar';
        };
    },
);

note '?foo=bar => /?foo=bar';
test_tcp(
    server => $server,
    client => sub {
        my $port = shift;
        my $furl = Furl::HTTP->new(bufsize => 10, timeout => 3);

        do {
            my (undef, $code, $msg, $headers, $content) = $furl->request(
                port       => $port,
                path_query => '?foo=bar',
                host       => '127.0.0.1',
            );
            is $code, 200, "code";
            is $msg, "OK" , "msg";
            is $content, "/?foo=bar", "return path query";
        };

        do {
            my $path_query = '?foo=bar';
            my ( undef, $code, $msg, $headers, $content ) = $furl->request(
                url    => "http://127.0.0.1:$port$path_query",
                method => 'GET',
            );
            is $code, 200, 'code';
            is $msg, 'OK', 'msg';
            is $content, '/?foo=bar';
        };
    },
);

done_testing;