APR-HTTP-Headers-Compat
view release on metacpan or search on metacpan
inc/MyBuilder.pm view on Meta::CPAN
)
);
}
sub ACTION_tidy {
my $self = shift;
my @extra = qw( Build.PL );
my %found_files = map { %$_ } $self->find_pm_files,
$self->_find_file_by_type( 'pm', 't' ),
$self->_find_file_by_type( 'pm', 'inc' ),
$self->_find_file_by_type( 't', 't' );
my @files = ( keys %found_files,
map { $self->localize_file_path( $_ ) } @extra );
for my $file ( @files ) {
system 'perltidy', '-b', $file;
unlink "$file.bak" if $? == 0;
}
}
lib/APR/HTTP/Headers/Compat.pm view on Meta::CPAN
# Normally you'll be given the table - we're creating one here for the
# sake of the example
my $table = APR::Table::make( APR::Pool->new, 1 );
# Wrap the table so it can be used as an HTTP::Headers instance
my $h = APR::HTTP::Headers::Compat->new( $table );
Optionally header initialisers may be passed:
my $h = APR::HTTP::Headers::Compat->new( $table,
'Content-type' => 'text/plain'
);
=cut
sub new {
my ( $class, $table ) = ( shift, shift );
my %self = %{ $class->SUPER::new( @_ ) };
tie %self, 'APR::HTTP::Headers::Compat::MagicHash', $table, %self;
return bless \%self, $class;
}
t/compat/base/headers.t view on Meta::CPAN
is( j( $h->clone->remove_header( "Foo" ) ), 1 );
is( j( $h->clone->remove_header( "Bar" ) ), 2 );
is( j( $h->clone->remove_header( "Baz" ) ), "2|3" );
is( j( $h->clone->remove_header( qw(Foo Bar Baz Not-There) ) ),
"1|2|2|3" );
is( j( $h->clone->remove_header( "Not-There" ) ), "" );
$h = mk(
allow => "GET",
content => "none",
content_type => "text/html",
content_md5 => "dummy",
content_encoding => "gzip",
content_foo => "bar",
last_modified => "yesterday",
expires => "tomorrow",
etag => "abc",
date => "today",
user_agent => "libwww-perl",
zoo => "foo",
);
t/compat/base/headers.t view on Meta::CPAN
is( $h->as_string, "" );
undef( $h2 );
$h = mk;
is( $h->header_field_names, 0 );
is( j( $h->header_field_names ), "" );
$h = mk(
etag => 1,
foo => [ 2, 3 ],
content_type => "text/plain"
);
is( $h->header_field_names, 3 );
is( j( $h->header_field_names ), "ETag|Content-Type|Foo" );
{
my @tmp;
$h->scan( sub { push( @tmp, @_ ) } );
is( j( @tmp ), "ETag|1|Content-Type|text/plain|Foo|2|Foo|3" );
@tmp = ();
t/compat/base/headers.t view on Meta::CPAN
is($h->$field(time), undef);
ok((time - $h->$field) =~ /^[01]$/);
EOT
}
is( j( $h->header_field_names ),
"Date|If-Modified-Since|If-Unmodified-Since|Expires|Last-Modified"
);
}
$h->clear;
is( $h->content_type, "" );
is( $h->content_type( "text/html" ), "" );
is( $h->content_type, "text/html" );
is( $h->content_type( " TEXT / HTML " ), "text/html" );
is( $h->content_type, "text/html" );
is( j( $h->content_type ), "text/html" );
is( $h->content_type( "text/html;\n charSet = \"ISO-8859-1\"; Foo=1 " ),
"text/html" );
is( $h->content_type, "text/html" );
is( j( $h->content_type ),
"text/html|charSet = \"ISO-8859-1\"; Foo=1 " );
is( $h->header( "content_type" ),
"text/html;\n charSet = \"ISO-8859-1\"; Foo=1 " );
ok( $h->content_is_html );
ok( !$h->content_is_xhtml );
ok( !$h->content_is_xml );
$h->content_type( "application/xhtml+xml" );
ok( $h->content_is_html );
ok( $h->content_is_xhtml );
ok( $h->content_is_xml );
is( $h->content_type( "text/html;\n charSet = \"ISO-8859-1\"; Foo=1 " ),
"application/xhtml+xml" );
is( $h->content_encoding, undef );
is( $h->content_encoding( "gzip" ), undef );
is( $h->content_encoding, "gzip" );
is( j( $h->header_field_names ), "Content-Encoding|Content-Type" );
is( $h->content_language, undef );
is( $h->content_language( "no" ), undef );
is( $h->content_language, "no" );
t/compat/base/headers.t view on Meta::CPAN
Authorization: Basic dTpw
Proxy-Authorization: Basic dTI6cDI=
Proxy-Authenticate: bar
WWW-Authenticate: bar
EOT
#---- old tests below -----
$h = mk(
mime_version => "1.0",
content_type => "text/html"
);
$h->header( URI => "http://www.oslonett.no/" );
is( $h->header( "MIME-Version" ), "1.0" );
is( $h->header( 'Uri' ), "http://www.oslonett.no/" );
$h->header(
"MY-header" => "foo",
"Date" => "somedate",
t/compat/base/headers.t view on Meta::CPAN
skip "Can't store references" => 1;
require URI;
$h->header( URI => URI->new( "http://www.perl.org" ) );
is( $h->header( "URI" )->scheme, "http" );
}
$h->clear;
is( $h->as_string, "" );
$h->content_type( "text/plain" );
$h->header( content_md5 => "dummy" );
$h->header( "Content-Foo" => "foo" );
$h->header( Location => "http:", xyzzy => "plugh!" );
is( $h->as_string, <<EOT);
Location: http:
Content-MD5: dummy
Content-Type: text/plain
Content-Foo: foo
Xyzzy: plugh!
t/compat/base/headers.t view on Meta::CPAN
Xyzzy: plugh!
EOT
is( $c->as_string, <<EOT);
Content-MD5: dummy
Content-Type: text/plain
Content-Foo: foo
EOT
$h = mk;
$h->content_type( "text/plain" );
$h->header( ":foo_bar", 1 );
$h->push_header( ":content_type", "text/html" );
is( j( $h->header_field_names ),
"Content-Type|:content_type|:foo_bar" );
is( $h->header( 'Content-Type' ), "text/plain" );
SKIP: {
skip "Namespace collision; can't be helped" => 1;
is( $h->header( ':Content_Type' ), undef );
}
is( $h->header( ':content_type' ), "text/html" );
is( $h->as_string, <<EOT);
Content-Type: text/plain
content_type: text/html
foo_bar: 1
EOT
# [RT#30579] IE6 appens "; length = NNNN" on If-Modified-Since (can we handle it)
$h = mk(
if_modified_since => "Sat, 29 Oct 1994 19:43:31 GMT; length=34343" );
is( gmtime( $h->if_modified_since ), "Sat Oct 29 19:43:31 1994" );
( run in 2.385 seconds using v1.01-cache-2.11-cpan-df04353d9ac )