--- /dev/null
+use strict;
+use warnings;
+
+my $payload_len = 64;
+our %args = (
+ client => {
+ func => sub {
+ my $self = shift;
+ my @request_stream = split("\n", <<"EOF", -1);
+HEAD http://foo.bar/$payload_len HTTP/1.1
+
+EOF
+ pop @request_stream;
+ print map { "$_\r\n" } @request_stream;
+ print STDERR map { ">>> $_\n" } @request_stream;
+ $self->{method} = 'HEAD';
+ http_response($self, $payload_len);
+ @request_stream = split("\n", <<"EOF", -1);
+GET http://foo.bar/$payload_len HTTP/1.1
+
+EOF
+ pop @request_stream;
+ print map { "$_\r\n" } @request_stream;
+ print STDERR map { ">>> $_\n" } @request_stream;
+ $self->{method} = 'GET';
+ http_response($self, $payload_len);
+ },
+ http_vers => ["1.1"],
+ nocheck => 1,
+ },
+ relayd => {
+ protocol => [ "http",
+ "match request path log \"*\"",
+ ],
+ loggrep => {
+ qr/, done, \[http:\/\/foo.bar\/$payload_len\] HEAD; \[http:\/\/foo.bar\/$payload_len\] GET/ => 1,
+ },
+ },
+ server => {
+ func => \&http_server,
+ nocheck => 1,
+ },
+);
+
+1;
-# $OpenBSD: funcs.pl,v 1.23 2017/07/14 14:41:03 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.24 2021/03/24 21:03:06 benno Exp $
# Copyright (c) 2010-2017 Alexander Bluhm <bluhm@openbsd.org>
#
}
}
}
- if ($chunked) {
- read_chunked($self);
- } else {
- undef $len unless defined($vers) && $vers eq "1.1";
- read_char($self, $len)
- if $method eq "GET";
+ if ($method ne 'HEAD') {
+ if ($chunked) {
+ read_chunked($self);
+ } else {
+ undef $len unless defined($vers) && $vers eq "1.1";
+ read_char($self, $len)
+ if $method eq "GET";
+ }
}
}
print STDERR "<<< $_\n";
($method, $url, $vers) = m{^(\w+) (.*) HTTP/(1\.[01])$}
or die ref($self), " http request not ok";
- $method =~ /^(GET|PUT)$/
+ $method =~ /^(GET|HEAD|PUT)$/
or die ref($self), " unknown method: $method";
($len, my @chunks) = $url =~ /(\d+)/g;
$len = [ $len, @chunks ] if @chunks;
my @response = ("HTTP/$vers 200 OK");
$len = defined($len) ? $len : scalar(split /|/,$url);
- if ($vers eq "1.1" && $method eq "GET") {
+ if ($vers eq "1.1" && $method =~ /^(GET|HEAD)$/) {
if (ref($len) eq 'ARRAY') {
push @response, "Transfer-Encoding: chunked";
} else {