X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Action-REST.git;a=blobdiff_plain;f=t%2Flib%2FTest%2FRest.pm;fp=t%2Flib%2FTest%2FRest.pm;h=854e5c808de979a8e01a52c76b77fd22ee512715;hp=704cff2f14efbc0b0bc3151a97313da7b226798d;hb=bc06b9a375c0c35d1f1248e618148afd70c165b9;hpb=6586d72d90cb43c286b142c638ac2900619ffe73 diff --git a/t/lib/Test/Rest.pm b/t/lib/Test/Rest.pm index 704cff2..854e5c8 100644 --- a/t/lib/Test/Rest.pm +++ b/t/lib/Test/Rest.pm @@ -26,8 +26,15 @@ sub new { my $sub = lc($method); *$sub = sub { my $self = shift; - my %p = validate( @_, { url => { type => SCALAR }, }, ); + my %p = validate( + @_, + { + url => { type => SCALAR }, + headers => { type => HASHREF, default => {} }, + }, + ); my $req = HTTP::Request->new( "$method" => $p{'url'} ); + $req->header( $_ => $p{headers}{$_} ) for keys %{ $p{headers} }; $req->content_type( $self->{'content_type'} ); return $req; }; @@ -44,9 +51,11 @@ sub new { { url => { type => SCALAR }, data => 1, + headers => { type => HASHREF, default => {} }, }, ); my $req = HTTP::Request->new( "$method" => $p{'url'} ); + $req->header( $_ => $p{headers}{$_} ) for keys %{ $p{headers} }; $req->content_type( $self->{'content_type'} ); $req->content_length( do { use bytes; length( $p{'data'} ) }