summaryrefslogtreecommitdiffstats
path: root/LayoutTests/http/tests/cookies/resources/clearCookies.cgi
blob: 27896b7db28a25e2c34c2853ea4b0e201e64fd92 (plain)
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
#!/usr/bin/perl -wT
use strict;

print "Content-Type: text/plain\n";
print "Cache-Control: no-store\n";
print 'Cache-Control: no-cache="set-cookie"' . "\n";

my $cookie = $ENV{"HTTP_CLEAR_COOKIE"};

if ($cookie =~ /Max-Age/i) {
    $cookie =~ s/Max-Age *= *[0-9]+/Max-Age=0/i;
} else {
    $cookie .= ";" unless ($cookie =~ m/;$/);
    $cookie .= " " unless ($cookie =~ m/ $/);
    $cookie .= "Max-Age=0";
}

if ($cookie =~ /Expires/i) {
    # Set the "Expires" field to UNIX epoch
    $cookie =~ s/Expires *= *[^;]+/Expires=Thu, 01 Jan 1970 00:00:00 GMT/i;
} else {
    $cookie .= ";" unless ($cookie =~ m/;$/);
    $cookie .= " " unless ($cookie =~ m/ $/);
    $cookie .= "Expires=Thu, 01 Jan 1970 00:00:00 GMT";
}

print "Set-Cookie: $cookie\n\n";