Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Revision history for HTTP-Message

{{$NEXT}}
- now handling HTTP method '0' (Karen Etheridge)

7.00 2024-10-07 15:31:56Z
- Stop transforming LF into CRLF. Fixes #69 (GH#196) (Olaf Alders)
Expand Down
5 changes: 3 additions & 2 deletions lib/HTTP/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@
my($eol) = @_;
$eol = "\n" unless defined $eol;

my $req_line = $self->method || "-";
# method must be at least one char, matching ^[a-zA-Z0-9!#$%&'*+.^_`|~-]+$
my $req_line = (length $self->method) ? $self->method : "-";

Check failure on line 122 in lib/HTTP/Request.pm

View workflow job for this annotation

GitHub Actions / Perl 5.10 on macos-latest

Use of uninitialized value in length
my $uri = $self->uri;
$uri = (defined $uri) ? $uri->as_string : "-";
$req_line .= " $uri";
Expand All @@ -131,7 +132,7 @@
sub dump
{
my $self = shift;
my @pre = ($self->method || "-", $self->uri || "-");
my @pre = ((length $self->method) ? $self->method : "-", (defined $self->uri) ? $self->uri : "-");

Check failure on line 135 in lib/HTTP/Request.pm

View workflow job for this annotation

GitHub Actions / Perl 5.10 on macos-latest

Use of uninitialized value in length

Check failure on line 135 in lib/HTTP/Request.pm

View workflow job for this annotation

GitHub Actions / Perl 5.10 on macos-latest

Use of uninitialized value in length
if (my $prot = $self->protocol) {
push(@pre, $prot);
}
Expand Down
12 changes: 11 additions & 1 deletion t/request.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use strict;
use warnings;

use Test::More;
plan tests => 39;
plan tests => 43;

use HTTP::Request;
use Try::Tiny qw( catch try );
Expand Down Expand Up @@ -166,3 +166,13 @@ $r2 = HTTP::Request->parse('methonly http://www.example.com/');
is( $r2->method, 'methonly' );
is( $r2->uri, 'http://www.example.com/' );
is( $r2->protocol, undef );

my $r3 = HTTP::Request->new(0 => "0");
is($r3->method, '0', '0 is a valid HTTP method');
is($r3->uri, '0', '0 is a valid URI');
is($r3->as_string, "0 0\n\n", 'parsed zero method, zero uri req');
is($r3->dump, <<EOT, 'dumped zero method, zero uri req');
0 0

(no content)
EOT
Loading