1# Test parsing of invalid chunk length values
2# We force multiple connections since relayd will abort the connection
3# when it encounters a bogus chunk size.
4#
5
6use strict;
7use warnings;
8
9my @lengths = (7, 6, 5, 4, 3, 2);
10my @chunks = ("0x4", "+3", "-0", "foo", "dead beef", "Ff0");
11our %args = (
12    client => {
13	func => sub {
14	    my $self = shift;
15	    my $chunk = shift(@chunks);
16	    $self->{redo} = int(@chunks);
17	    print <<"EOF";
18PUT /4/3 HTTP/1.1
19Host: foo.bar
20Transfer-Encoding: chunked
21
22$chunk
23
24EOF
25	    foreach (@lengths) {
26		print STDERR "LEN: $_\n";
27	    }
28	    # relayd does not forward the first chunk if the second one
29	    # is invalid.  So do not expect any response.
30	    #http_response($self, "without len");
31	},
32	http_vers => ["1.1"],
33	lengths => \@lengths,
34	method => "PUT",
35    },
36    relayd => {
37	protocol => [ "http",
38	    "match request header log foo",
39	    "match response header log bar",
40	],
41	loggrep => {
42	    qr/, invalid chunk size, PUT/ => 5,
43	},
44    },
45    server => {
46	func => \&http_server,
47	nocheck => 1,
48    },
49    lengths => \@lengths,
50);
51
521;
53