Subject: | TWMC doesn't work nice with cookies |
I've worked around that changing '_make_request' as follows, but this should probably be
integrated in TWMC:
### XXX this needs to be set for Test::WWW::Mech::Cat, as using a
### non-schemed URI makes HTTP::Cookies not add a cookie to the
### header. Setting this var prefixes every path with the hostname
### XXX at least broken in 0.42. Fix is to add to T:W:M:C->_make_request,
{ my $code = Test::WWW::Mechanize::Catalyst->can( '_make_request' );
no warnings 'redefine';
*Test::WWW::Mechanize::Catalyst::_make_request = sub {
my ( $self, $request ) = @_;
### build a new uri, adding the hostname
if( not $request->uri->can('host') or
$request->uri->host ne 'localhost'
) {
### if there's no leading slash, make sure we add it
my $delim = $request->uri->as_string =~ m|^/| ? '' : '/';
$request->uri( URI->new( TEST_HOSTNAME .$delim. $request->uri ) );
}
$code->( $self, $request );
}
}