11b3c3ba0Sbluhm# test chunked http connection over http relay invoking the callback
21b3c3ba0Sbluhm# The client writes a bad chunk length in the second chunk.
31b3c3ba0Sbluhm# Check that the relay handles the input after the error correctly.
41b3c3ba0Sbluhm
51b3c3ba0Sbluhmuse strict;
61b3c3ba0Sbluhmuse warnings;
71b3c3ba0Sbluhm
81b3c3ba0Sbluhmmy @lengths = ([4, 3]);
91b3c3ba0Sbluhmour %args = (
101b3c3ba0Sbluhm    client => {
111b3c3ba0Sbluhm	func => sub {
121b3c3ba0Sbluhm	    my $self = shift;
131b3c3ba0Sbluhm	    print <<'EOF';
141b3c3ba0SbluhmPUT /4/3 HTTP/1.1
151b3c3ba0SbluhmHost: foo.bar
161b3c3ba0SbluhmTransfer-Encoding: chunked
171b3c3ba0Sbluhm
18*17eafa10SbluhmEOF
19*17eafa10Sbluhm	    ${$self->{server}}->up;
20*17eafa10Sbluhm	    print <<'EOF';
211b3c3ba0Sbluhm4
221b3c3ba0Sbluhm123
231b3c3ba0Sbluhm
241b3c3ba0SbluhmXXX
251b3c3ba0Sbluhm3
261b3c3ba0Sbluhm12
271b3c3ba0Sbluhm
281b3c3ba0Sbluhm0
291b3c3ba0Sbluhm
301b3c3ba0SbluhmEOF
311b3c3ba0Sbluhm	    print STDERR "LEN: 4\n";
321b3c3ba0Sbluhm	    print STDERR "LEN: 3\n";
331b3c3ba0Sbluhm	    # relayd does not forward the first chunk if the second one
341b3c3ba0Sbluhm	    # is invalid.  So do not expect any response.
351b3c3ba0Sbluhm	    #http_response($self, "without len");
361b3c3ba0Sbluhm	},
371b3c3ba0Sbluhm	http_vers => ["1.1"],
381b3c3ba0Sbluhm	lengths => \@lengths,
391b3c3ba0Sbluhm	method => "PUT",
401b3c3ba0Sbluhm    },
411b3c3ba0Sbluhm    relayd => {
421b3c3ba0Sbluhm	protocol => [ "http",
431b3c3ba0Sbluhm	    "match request header log foo",
441b3c3ba0Sbluhm	    "match response header log bar",
451b3c3ba0Sbluhm	],
461b3c3ba0Sbluhm	loggrep => {
471b3c3ba0Sbluhm	    qr/, invalid chunk size, PUT/ => 1,
481b3c3ba0Sbluhm	},
491b3c3ba0Sbluhm    },
501b3c3ba0Sbluhm    server => {
51*17eafa10Sbluhm	down => "Server missing chunk size",
52*17eafa10Sbluhm	func => sub { errignore(@_); http_server(@_); },
531b3c3ba0Sbluhm	nocheck => 1,
541b3c3ba0Sbluhm    },
551b3c3ba0Sbluhm    lengths => \@lengths,
561b3c3ba0Sbluhm);
571b3c3ba0Sbluhm
581b3c3ba0Sbluhm1;
59