/
30_as_string.t
55 lines (42 loc) · 1.18 KB
/
30_as_string.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use strict;
use warnings;
use Test::MockTime qw/set_fixed_time/;
use CGI;
use CGI::Cookie;
use CGI::Header;
use Test::More tests => 2;
my $now = 1349043453;
set_fixed_time( $now );
my $CRLF = $CGI::CRLF;
my $cookie1 = CGI::Cookie->new(
-name => 'foo',
-value => 'bar',
);
my $cookie2 = CGI::Cookie->new(
-name => 'bar',
-value => 'baz',
);
{
my $header = CGI::Header->new(
-attachment => 'genome.jpg',
-charset => 'utf-8',
-cookie => [ $cookie1, $cookie2 ],
-expires => '+3d',
-nph => 1,
-p3p => [qw/CAP DSP LAW CURa/],
-target => 'ResultsWindow',
-type => 'text/plain',
);
$header->set( Ingredients => join "$CRLF ", qw/ham eggs bacon/ );
my $got = $header->as_string( $CRLF ) . $CRLF;
my $expected = CGI->new->header( $header->header );
is $got, $expected;
}
{
local $ENV{SERVER_SOFTWARE} = 'Apache/1.3.27 (Unix)';
local $ENV{SERVER_PROTOCOL} = 'HTTP/1.1';
my $header = CGI::Header->new( -nph => 1 );
my $got = $header->as_string( $CRLF ) . $CRLF;
my $expected = CGI->new->header( $header->header );
is $got, $expected;
}