3 # This is meant to be used on the raw output of an HTTP/1.1 connection
4 # to check that the chunks are all correctly laid out. It's easiest
5 # to use a tool like netcat to generate the output. This script
6 # *insists* that \r exist in the output.
8 # You can find netcat at avian.org:/src/hacks/nc110.tgz.
16 if (/^Transfer-Encoding:\s+chunked/i) {
19 last if ($_ eq "\r\n");
22 $is_chunked || die "wasn't chunked\n";
25 $_ = <> || die "unexpected end of file!\n";
27 m#^([0-9a-f]+) *\r$#i || die "bogus chunklen: $_";
29 my $chunklen = hex($1);
31 exit 0 if ($chunklen == 0);
37 read(ARGV, $data, $chunklen) == $chunklen || die "short read!\n";
39 $_ = <> || die "unexpected end of file!\n";
41 $_ eq "\r\n" || die "missing chunk trailer!\n";