Archive-Har
view release on metacpan or search on metacpan
},
{
"name": "expires",
"value": "-1"
}
],
"cookies": [],
"content": {
"size": 213057,
"mimeType": "text/html",
"text": "<!doctype html><html itemscope=\"\" itemtype=\"http://schema.org/WebPage\" lang=\"en-AU\"><head><meta content=\"/images/branding/googleg/1x/googleg_standard_color_128dp.png\" itemprop=\"image\"><link href=\"/images/branding/produ...
},
"redirectURL": "",
"headersSize": -1,
"bodySize": -1,
"_transferSize": 68060
},
"cache": {},
"timings": {
"blocked": 0.254000000040833,
"dns": -1,
},
{
"name": "expires",
"value": "Sat, 14 Apr 2018 22:51:30 GMT"
}
],
"cookies": [],
"content": {
"size": 436180,
"mimeType": "text/javascript",
"text": "/* _GlobalPrefix_ */\n/* _Module_:quantum */\ntry{\nvar s_,s_aaa=\"function\"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(c.get||c.set)throw new TypeError(\"ES3 does not support getters and setters.\"...
},
"redirectURL": "",
"headersSize": -1,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": 0.133999999889056,
"dns": -1,
},
{
"name": "expires",
"value": "Sat, 14 Apr 2018 23:08:00 GMT"
}
],
"cookies": [],
"content": {
"size": 108222,
"mimeType": "text/javascript",
"text": "/* _GlobalPrefix_ */\n/* _Module_:sy1p */\ntry{\nvar s_vja,s_wja,s_1i,s_xja,s_2i,s_yja={};s_D(\"sy1p\");var s_3i=function(a){s_K(this,a,0,2,null,null)};s_g(s_3i,s_J);s_3i.prototype.jh=function(){return s_L(this,1)};var s_zja={};v...
},
"redirectURL": "",
"headersSize": -1,
"bodySize": -1,
"_transferSize": 36140
},
"cache": {},
"timings": {
"blocked": 0.595999999859487,
"dns": -1,
},
{
"name": "expires",
"value": "Fri, 13 Apr 2018 21:01:54 GMT"
}
],
"cookies": [],
"content": {
"size": 136732,
"mimeType": "text/javascript",
"text": "/* _GlobalPrefix_ */\nthis.gbar_=this.gbar_||{};(function(_){var window=this;\n/* _Module_:syp */\ntry{\nvar On=function(){};_.y(On,Error);_.Pn=function(){this.b=\"pending\";this.B=[];this.w=this.C=void 0};_.ae(_.Pn);var Qn=funct...
},
"redirectURL": "",
"headersSize": -1,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": 0.233000000207539,
"dns": -1,
},
"serverIPAddress": "216.58.196.146",
"connection": "1817",
"pageref": "page_4"
}
]
}
}
_CHROME_RESULTS_
ok($har->string($chrome_string), "Successfully read Chrome har archive for https://www.google.com/");
ok($har->version() eq '1.2', "INPUT: Chrome produces a version 1.2 http archive");
ok($har->creator()->name() eq 'WebInspector', "INPUT: Chrome's creator name is 'WebInspector'");
ok($har->creator()->version() eq '537.36', "INPUT: Chrome's creator version is '537.36'");
ok(!defined $har->creator()->comment(), "INPUT: Chrome's creator comment is not used");
my $chrome_ref = $har->hashref();
ok(!exists $chrome_ref->{log}->{entries}->[0]->{request}->{postData}, "Empty postData entry stripped from Chrome output");
t/fiddler2.t view on Meta::CPAN
use Test::More tests => 6;
use Archive::Har();
use JSON();
my $har = Archive::Har->new();
my $fiddler_string = <<'_FIDDLER2_RESULTS_';
{"log":{"creator":{"comment":"http://www.fiddler2.com", "version":"4.6.0.2", "name":"Fiddler"}, "entries":[{"startedDateTime":"2015-09-05T17:11:08.5888671+10:00", "response":{"headersSize":306, "httpVersion":"HTTP/1.1", "content":{"compression":0,...
_FIDDLER2_RESULTS_
ok($har->string($fiddler_string), "Successfully read Fiddler har archive for http://search.cpan.org/recent");
ok($har->version() eq '1.2', "INPUT: Fiddler produces a version 1.2 http archive");
ok($har->creator()->name() eq 'Fiddler', "INPUT: Fiddler's creator name is 'Fiddler'");
ok($har->creator()->version() eq '4.6.0.2', "INPUT: Fiddler's creator version is '4.6.0.2'");
ok($har->creator()->comment() eq 'http://www.fiddler2.com', "INPUT: Fiddler's creator comment is 'http://www.fiddler2.com'");
my $fiddler_ref = $har->hashref();
ok(!exists $fiddler_ref->{log}->{entries}->[0]->{request}->{postData}, "Empty postData entry stripped from Fiddler output");
t/firebug_cookies_n_cache.t view on Meta::CPAN
},
"serverIPAddress": "74.125.237.116",
"connection": "443"
}
]
}
}
_FIREBUG_RESULTS_
ok($har->string($firebug_gmail_string), "Successfully read firebug har archive for https://accounts.google.com");
my (undef, $secondEntry) = $har->entries();
ok(scalar $secondEntry->request()->cookies() == 1, "INPUT: Firebug's archive second entry request has a cookie list with 1 entries");
my ($cookie) = $secondEntry->request->cookies();
ok($cookie->name() eq 'GMAIL_RTT', "INPUT: Firebug's archive second entry request cookie has a name of 'GMAIL_RTT'");
ok($cookie->value() eq '270', "INPUT: Firebug's archive second entry request cookie has a value of '270'");
($cookie) = $secondEntry->response()->cookies();
ok($cookie->name() eq 'accountrecoverylocale', "INPUT: Firebug's archive second entry response cookie has a name of 'accountrecoverylocale'");
ok($cookie->value() eq 'en', "INPUT: Firebug's archive second entry response cookie has a name of 'en'");
ok($cookie->expires() eq '2012-04-10T10:22:42.000+10:00', "INPUT: Firebug's archive second entry response cookie has a expires of '2012-04-10T10:22:42.000+10:00'");
ok($cookie->path() eq '/accounts/recovery', "INPUT: Firebug's archive second entry response cookie has a path of '/accounts/recovery'");
ok($cookie->http_only(), "INPUT: Firebug's archive second entry response cookie has httpOnly set to true");
ok(not(defined($cookie->secure())), "INPUT: Firebug's archive second entry response cookie does not have secure set at all");
my $firebug_ref = $har->hashref();
ok(scalar @{$firebug_ref->{log}->{entries}->[1]->{request}->{cookies}} == 1, "OUTPUT: Firebug's archive second entry request has a cookie list with 1 entries");
ok($firebug_ref->{log}->{entries}->[1]->{request}->{cookies}->[0]->{name} eq 'GMAIL_RTT', "OUTPUT: Firebug's archive second entry request has a name of 'GMAIL_RTT'");
ok($firebug_ref->{log}->{entries}->[1]->{request}->{cookies}->[0]->{value} eq '270', "OUTPUT: Firebug's archive second entry request has a value of '270'");
ok($firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{name} eq 'accountrecoverylocale', "OUTPUT: Firebug's archive second entry response has a name of 'accountrecoverylocale'");
ok($firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{value} eq 'en', "OUTPUT: Firebug's archive second entry request has a value of 'en'");
ok($firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{expires} eq '2012-04-10T10:22:42.000+10:00', "OUTPUT: Firebug's archive second entry request has a expires of '2012-04-10T10:22:42.000+10:00'");
ok($firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{path} eq '/accounts/recovery', "OUTPUT: Firebug's archive second entry request has a path of '/accounts/recovery'");
ok($firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{httpOnly}, "OUTPUT: Firebug's archive second entry request has httpOnly set to true");
ok(not(exists $firebug_ref->{log}->{entries}->[1]->{response}->{cookies}->[0]->{secure}), "OUTPUT: Firebug's archive second entry request does not have a secure key at all");
t/firebug_get.t view on Meta::CPAN
"value": "Accept-Encoding"
},
{
"name": "Content-Encoding",
"value": "gzip"
}
],
"content": {
"mimeType": "application/x-javascript",
"size": 176455,
"text": "if(typeof YAHOO==\"undefined\"||!YAHOO){var YAHOO={}}YAHOO.namespace=function(){var a=arguments,h=null,k,l,j;for(k=0;k<a.length;k=k+1){j=(\"\"+a[k]).split(\".\");h=YAHOO;for(l=(j[0]==\"YAHOO\")?1:0;l<j.length;l=l+1){h[j[l]]=h[j[l...
},
"redirectURL": "",
"headersSize": 344,
"bodySize": 56690
},
"cache": {},
"timings": {
"blocked": 297,
"dns": 0,
"connect": 0,
t/firebug_get.t view on Meta::CPAN
"receive": 0
},
"serverIPAddress": "46.51.216.187",
"connection": "443"
}
]
}
}
_FIREBUG_RESULTS_
ok($har->string($firebug_get_string), "Successfully read firebug har archive for https://duckduckgo.com/?q=http+archive+specification");
ok($har->version() eq '1.1', "INPUT: Firebug produces a version 1.1 http archive");
ok($har->creator()->name() eq 'Firebug', "INPUT: Firebug's creator name is 'Firebug'");
ok($har->creator()->version() eq '1.9', "INPUT: Pingdom's creator version is '1.9'");
ok(not(defined $har->creator()->comment()), "INPUT: Pingdom's creator comment is not defined");
ok($har->browser()->name() eq 'Firefox', "INPUT: Firebug's browser name is 'Firefox'");
ok($har->browser()->version() eq '11.0', "INPUT: Firebug's browser version is '11.0'");
ok(not(defined $har->browser()->comment()), "INPUT: Firebug's browser comment is not defined");
($firstEntry) = $har->entries();
ok(scalar $firstEntry->request()->headers() == 9, "INPUT: Firebug's archive first entry request has 9 headers");
my @headers = $firstEntry->request()->headers();
ok($headers[1]->name() eq 'User-Agent', "INPUT: Firebug's archive first entry second header has a name of 'User-Agent'");
ok($headers[1]->value() eq 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/2010.111 Firefox/11.0', "INPUT: Firebug's archive first entry second header has a value of 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0'");
my @queryString = $firstEntry->request()->query_string();
ok($queryString[0]->name() eq 'q', "INPUT: Firebug's archive first entry first query parameter has a name of 'q'");
ok($queryString[0]->value() eq 'http archive specification', "INPUT: Firebug's archive first entry first query parameter has a value of 'http archive specification'");
ok($firstEntry->request()->headers_size(undef) == 394, "INPUT: Firebug's archive first entry request has a header size of 394");
ok(not(defined $firstEntry->request()->headers_size(-1)), "INPUT: Firebug's archive first entry request has a header size that is not defined (after being set to undef)");
ok(not(defined $firstEntry->request()->headers_size(394)), "INPUT: Firebug's archive first entry request has a header size that is not defined (after being set to -1)");
ok(not(defined $firstEntry->request()->body_size()), "INPUT: Firebug's archive first entry request has a body size that is not defined");
ok(not(defined $firstEntry->request()->post_data()), "INPUT: Firebug's archive first entry request has a post data reference that is not defined");
my $firebug_ref = $har->hashref();
ok($firebug_ref->{log}->{version} eq '1.1', "OUTPUT: Firebug produces a version 1.1 http archive");
ok($firebug_ref->{log}->{creator}->{name} eq 'Firebug', "OUTPUT: Firebug's creator name is 'Firebug'");
ok($firebug_ref->{log}->{creator}->{version} eq '1.9', "OUTPUT: Firebug's creator version is '1.9'");
ok(not(exists $firebug_ref->{log}->{creator}->{comment}), "OUTPUT: Firebug's creator comment does not exist");
ok($firebug_ref->{log}->{browser}->{name} eq 'Firefox', "OUTPUT: Firebug's browser name is 'Firefox'");
ok($firebug_ref->{log}->{browser}->{version} eq '11.0', "OUTPUT: Firebug's browser version is '11.0'");
ok(not(exists $firebug_ref->{log}->{browser}->{comment}), "OUTPUT: Firebug's browser comment does not exist");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{headers}->[1]->{name} eq 'User-Agent', "OUTPUT: Firebug's archive first entry second header has a name of 'User-Agent'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{headers}->[1]->{value} eq 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/2010.111 Firefox/11.0', "OUTPUT: Firebug's archive first entry second header has a value of 'Mozilla/5.0 (Windows NT 6.1...
ok($firebug_ref->{log}->{entries}->[0]->{request}->{queryString}->[0]->{name} eq 'q', "OUTPUT: Firebug's archive first entry first query parameter has a name of 'q'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{queryString}->[0]->{value} eq 'http archive specification', "OUTPUT: Firebug's archive first entry first query parameter has a value of 'http archive specification'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{headersSize} eq '394', "OUTPUT: Firebug's archive first entry has a header size of 394");
$firstEntry->request()->headers_size(undef);
$firebug_ref = $har->hashref();
ok($firebug_ref->{log}->{entries}->[0]->{request}->{headersSize} eq '-1', "OUTPUT: Firebug's archive first entry has a header size of '-1' (after being set to undef)");
$firstEntry->request()->headers_size(-1);
$firebug_ref = $har->hashref();
ok($firebug_ref->{log}->{entries}->[0]->{request}->{headersSize} eq '-1', "OUTPUT: Firebug's archive first entry has a header size of '-1' (after being set to -1)");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{bodySize} eq '-1', "OUTPUT: Firebug's archive first entry has a body size of '-1'");
ok(not(exists $firebug_ref->{log}->{entries}->[0]->{request}->{postData}), "OUTPUT: Firebug's archive first entry does not have a postData reference");
t/firebug_post.t view on Meta::CPAN
ok($har->string($firebug_post_string), "Successfully read firebug har archive for POSTed request for http://duckduckgo.com via Firefox search box");
my $har2 = Archive::Har->new();
$har2->string($firebug_post_string);
my $string1 = "$har";
my $string2 = $har2->string();
ok($string1 eq $string2, "JSON objects have the same sort order for hashes");
my $gzip = $har->gzip();
ok($gzip =~ /^\x1f\x8b/, "Gzipped har file has the correct magic number");
ok($har->gzip($gzip), "Successfully uncompressed a compressed har stream");
($firstEntry) = $har->entries();
ok($firstEntry->request()->method() eq 'POST', "INPUT: Firebug's archive first entry request has a method of 'POST'");
ok($firstEntry->request()->body_size() == 97, "INPUT: Firebug's archive first entry request has a body size of 97");
ok($firstEntry->request()->post_data()->mime_type() eq 'application/x-www-form-urlencoded', "INPUT: Firebug's archive first entry request has a post data mime type of 'application/x-www-form-urlencoded'");
ok(not(defined $firstEntry->request()->post_data()->text()), "INPUT: Firebug's archive first entry request has a post data text that is not defined");
ok(scalar $firstEntry->request()->post_data()->params() == 2, "INPUT: Firebug's archive first entry request has a post data with 2 parameters");
ok(scalar $firstEntry->request()->post_data()->params() == 2, "INPUT: Firebug's archive first entry request has a post data with 2 parameters");
my (undef, $secondParam) = $firstEntry->request()->post_data()->params();
ok($secondParam->name() eq 'q', "INPUT: Firebug's archive first entry request has a post data with the second parameter having a name of 'q'");
ok($secondParam->value() eq 'http archive format', "INPUT: Firebug's archive first entry request has a post data with the second parameter having a name of 'http archive format'");
ok(not(defined $secondParam->file_name()), "INPUT: Firebug's archive first entry request has a post data with the second parameter having a fileName returning undef");
ok(not(defined $secondParam->content_type()), "INPUT: Firebug's archive first entry request has a post data with the second parameter having a contentType returning undef");
ok($firstEntry->response()->status() == 200, "INPUT: Firebug's archive first entry response has a status of 200");
ok($firstEntry->response()->status_text() eq 'OK', "INPUT: Firebug's archive first entry response has a status text of 'OK'");
ok($firstEntry->response()->http_version() eq 'HTTP/1.1', "INPUT: Firebug's archive first entry response has an http version of 'HTTP/1.1'");
ok(scalar $firstEntry->response()->cookies() == 0, "INPUT: Pingdom's archive first entry response has an empty cookie list");
ok(scalar $firstEntry->response()->headers() == 8, "INPUT: Pingdom's archive first entry response has 8 headers");
@headers = $firstEntry->response()->headers();
ok($headers[0]->name() eq 'Server', "INPUT: Firebug's archive first entry response first header has a name of 'Server'");
ok($headers[0]->value() eq 'nginx', "INPUT: Firebug's archive first entry response first header has a value of 'nginx'");
ok($firstEntry->response()->content()->mime_type() eq 'text/html', "INPUT: Firebug's archive first entry response content has a mime type of 'text/html'");
ok($firstEntry->response()->content()->size() == 6730, "INPUT: Firebug's archive first entry response content has a size of 6730");
ok($firstEntry->response()->content()->text() =~ /^<!DOCTYPE HTML PUBLIC/, "INPUT: Firebug's archive first entry response content has a text value beginning with /^<!DOCTYPE HTML PUBLIC/");
ok($firstEntry->response()->redirect_url() eq '', "INPUT: Firebug's archive first entry response has a redirectURL of ''");
ok($firstEntry->response()->headers_size() == 253, "INPUT: Firebug's archive first entry response has a headersSize value of 253");
ok($firstEntry->response()->body_size() == 2673, "INPUT: Firebug's archive first entry response has a bodySize value of 2673");
ok($firstEntry->server_ip_address() eq '184.72.106.52', "INPUT: Firebug's archive first entry has a server ip address of '184.72.106.52'");
ok($firstEntry->connection() eq '443', "INPUT: Firebug's archive first entry has a connection value of '443'");
$firebug_ref = JSON::decode_json($har->string());
ok($firebug_ref->{log}->{entries}->[0]->{request}->{method} eq 'POST', "OUTPUT: Firebug's archive first entry request has method of 'POST'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{bodySize} eq '97', "OUTPUT: Firebug's archive first entry request has a body size of '97'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{mimeType} eq 'application/x-www-form-urlencoded', "OUTPUT: Firebug's archive first entry request has a post data mime type of 'application/x-www-form-urlencoded'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{text} eq '', "OUTPUT: Firebug's archive first entry request has a post data text of ''");
ok(scalar @{$firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{params}} == 2, "OUTPUT: Firebug's archive first entry request has a post data with 2 parameters");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{params}->[1]->{name} eq 'q', "OUTPUT: Firebug's archive first entry request has a post data with the second parameter having a name of 'q'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{params}->[1]->{value} eq 'http archive format', "OUTPUT: Firebug's archive first entry request has a post data with the second parameter having a name of 'http archive format'");
ok(not(exists $firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{params}->[1]->{fileName}), "OUTPUT: Firebug's archive first entry request has a post data with the second parameter not having a fileName attribute");
ok(not(exists $firebug_ref->{log}->{entries}->[0]->{request}->{postData}->{params}->[1]->{contentType}), "OUTPUT: Firebug's archive first entry request has a post data with the second parameter not having a contentType attribute");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{status} == 200, "OUTPUT: Firebug's archive first entry response has a status of 200");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{statusText} eq 'OK', "OUTPUT: Firebug's archive first entry response has a status text of 'OK'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{httpVersion} eq 'HTTP/1.1', "OUTPUT: Firebug's archive first entry response has an http version of 'HTTP/1.1'");
ok(scalar @{$firebug_ref->{log}->{entries}->[0]->{response}->{cookies}} == 0, "OUTPUT: Firebug's archive first entry response has an empty cookie list");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{headers}->[0]->{name} eq 'Server', "OUTPUT: Firebug's archive first entry response first header has a name of 'Server'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{headers}->[0]->{value} eq 'nginx', "OUTPUT: Firebug's archive first entry response first header has a name of 'nginx'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{content}->{mimeType} eq 'text/html', "OUTPUT: Firebug's archive first entry response content has a mime type of 'text/html'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{content}->{size} == 6730, "OUTPUT: Firebug's archive first entry response content has a size of 6730");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{content}->{text} =~ /^<!DOCTYPE HTML PUBLIC/, "OUTPUT: Firebug's archive first entry response content has a text beginning with /^<!DOCTYPE HTML PUBLIC/");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{redirectURL} eq '', "OUTPUT: Firebug's archive first entry response has a redirect url value of ''");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{headersSize} == 253, "OUTPUT: Firebug's archive first entry response has a headers size of 253");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{bodySize} == 2673, "OUTPUT: Firebug's archive first entry response has a headers size of 2673");
ok($firebug_ref->{log}->{entries}->[0]->{serverIPAddress} eq '184.72.106.52', "OUTPUT: Firebug's archive first entry has a server ip address of '184.72.106.52'");
ok($firebug_ref->{log}->{entries}->[0]->{connection} eq '443', "OUTPUT: Firebug's archive first entry has a connection of '443'");
t/httpwatch_cookies_n_cache.t view on Meta::CPAN
},
"serverIPAddress" : "74.125.237.112",
"connection" : "4"
}
]
}
}
_HTTPWATCH_RESULTS_
ok($har->string($httpwatch_gmail_string), "Successfully read firebug har archive for https://accounts.google.com");
my ($firstPage) = $har->pages();
ok($firstPage->page_timings()->_renderStart() == 2928, "INPUT: HttpWatch's archive first page pageTimings for _renderStart is 2928");
eval { $firstPage->page_timings->notInTheSpec() };
ok($@ =~ /notInTheSpec is not specified in the HAR 1.2 spec and does not start with an underscore/, "INPUT: Correct exception thrown for a non-conforming field name:$@");
my ($firstEntry) = $har->entries();
ok($firstEntry->response()->redirect_url() eq 'https://www.google.com/accounts/recovery?hl=en&gaps&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F', "INPUT: HttpWatch's archive first entry response has a redirectURL of 'https://www.goog...
ok($firstEntry->response()->content()->compression() == 73, "INPUT: HttpWatch's archive first entry response content has a compression of 73");
ok(not(defined $firstEntry->cache()->before_request()), "INPUT: HttpWatch's archive first entry cache has a undefined beforeRequest");
ok($firstEntry->cache()->after_request()->last_access() eq '2012-04-03T22:13:50.000Z', "INPUT: HttpWatch's archive first entry cache has a afterRequest lastAccess of '2012-04-03T22:13:50.000Z'");
ok($firstEntry->cache()->after_request()->etag() eq '', "INPUT: HttpWatch's archive first entry cache has a afterRequest eTag is set to the empty string");
ok($firstEntry->cache()->after_request()->hit_count() == 1, "INPUT: HttpWatch's archive first entry cache has a afterRequest hitCount is equal to 1");
ok(scalar $firstEntry->request()->cookies() == 1, "INPUT: HttpWatch's archive first entry request has a cookie list with 1 entries");
my ($cookie) = $firstEntry->request->cookies();
ok($cookie->name() eq 'PREF', "INPUT: HttpWatch's archive first entry request cookie has a name of 'PREF'");
ok($cookie->value() eq 'ID=31245dd052940995:TM=1333416734:LM=1333416734:S=GVCghq5oz8F4iPqS', "INPUT: HttpWatch's archive first entry request cookie has a value of 'ID=31245dd052940995:TM=1333416734:LM=1333416734:S=GVCghq5oz8F4iPqS'");
ok($cookie->path() eq '/', "INPUT: HttpWatch's archive first entry request cookie has a path of '/'");
ok($cookie->domain() eq '.google.com', "INPUT: HttpWatch's archive first entry request cookie has a domain of '.google.com'");
ok($cookie->expires() eq '2014-04-03T01:32:16.000Z', "INPUT: HttpWatch's archive first entry request cookie has a domain of '2014-04-03T01:32:16.000Z'");
ok((defined $cookie->http_only()) && (not($cookie->http_only())), "INPUT: HttpWatch's archive first entry request cookie has httpOnly set to false");
ok((defined $cookie->secure()) && (not($cookie->secure())), "INPUT: HttpWatch's archive first entry request cookie has secure set to false");
($cookie) = $firstEntry->response()->cookies();
ok($cookie->name() eq 'GAPS', "INPUT: HttpWatch's archive first entry response cookie has a name of 'GAPS'");
ok($cookie->value() eq '1:UXm7kjQDHHUZVCIzJEuqpbo7xhUpSw:pesWZreBW2aeymnv', "INPUT: HttpWatch's archive first entry response cookie has a name of '1:UXm7kjQDHHUZVCIzJEuqpbo7xhUpSw:pesWZreBW2aeymnv'");
ok($cookie->expires() eq '2014-04-03T22:13:46.000Z', "INPUT: HttpWatch's archive first entry response cookie has a expires of '2014-04-03T22:13:46.000Z'");
ok($cookie->path() eq '/', "INPUT: HttpWatch's archive first entry response cookie has a path of '/'");
ok($cookie->http_only(), "INPUT: HttpWatch's archive first entry response cookie has httpOnly set to true");
ok($cookie->secure(), "INPUT: HttpWatch's archive first entry response cookie has secure set to true");
my $firebug_ref = $har->hashref();
ok($firebug_ref->{log}->{pages}->[0]->{pageTimings}->{_renderStart} == 2928, "OUTPUT: HttpWatch's archive first page pageTimings for _renderStart is 2928");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{redirectURL} eq 'https://www.google.com/accounts/recovery?hl=en&gaps&service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F', "OUTPUT: HttpWatch's archive first entry response has a redirect...
ok($firebug_ref->{log}->{entries}->[0]->{response}->{content}->{compression} == 73, "OUTPUT: HttpWatch's archive first entry response content has a compression of 73");
ok((exists $firebug_ref->{log}->{entries}->[0]->{cache}->{beforeRequest}) && (not(defined $firebug_ref->{log}->{entries}->[0]->{beforeRequest})), "OUTPUT: HttpWatch's archive first entry cache has a undefined beforeRequest");
ok($firebug_ref->{log}->{entries}->[0]->{cache}->{afterRequest}->{lastAccess} eq '2012-04-03T22:13:50.000Z', "OUTPUT: HttpWatch's archive first entry cache has a afterRequest lastAccess of '2012-04-03T22:13:50.000Z'");
ok($firebug_ref->{log}->{entries}->[0]->{cache}->{afterRequest}->{eTag} eq '', "OUTPUT: HttpWatch's archive first entry cache has a afterRequest eTag of ''");
ok($firebug_ref->{log}->{entries}->[0]->{cache}->{afterRequest}->{hitCount} == 1, "OUTPUT: HttpWatch's archive first entry cache has a afterRequest hitCount of 1");
ok(scalar @{$firebug_ref->{log}->{entries}->[0]->{request}->{cookies}} == 1, "OUTPUT: HttpWatch's archive first entry request has a cookie list with 1 entries");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{name} eq 'PREF', "OUTPUT: HttpWatch's archive first entry request has a name of 'PREF'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{value} eq 'ID=31245dd052940995:TM=1333416734:LM=1333416734:S=GVCghq5oz8F4iPqS', "OUTPUT: HttpWatch's archive first entry request has a value of 'ID=31245dd052940995:TM=1333416734:LM=...
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{path} eq '/', "OUTPUT: HttpWatch's archive first entry request has a path of '/'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{domain} eq '.google.com', "OUTPUT: HttpWatch's archive first entry request has a domain of '.google.com'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{expires} eq '2014-04-03T01:32:16.000Z', "OUTPUT: HttpWatch's archive first entry request has a expires of '2014-04-03T01:32:16.000Z'");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{httpOnly} eq '0', "OUTPUT: HttpWatch's archive first entry request has a httpOnly set to false");
ok($firebug_ref->{log}->{entries}->[0]->{request}->{cookies}->[0]->{secure} eq '0', "OUTPUT: HttpWatch's archive first entry request has a httpOnly set to false");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{name} eq 'GAPS', "OUTPUT: HttpWatch's archive first entry response has a name of 'GAPS'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{value} eq '1:UXm7kjQDHHUZVCIzJEuqpbo7xhUpSw:pesWZreBW2aeymnv', "OUTPUT: HttpWatch's archive first entry response has a value of '1:UXm7kjQDHHUZVCIzJEuqpbo7xhUpSw:pesWZreBW2aeymnv'")...
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{path} eq '/', "OUTPUT: HttpWatch's archive first entry response has a path of '/'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{domain} eq 'accounts.google.com', "OUTPUT: HttpWatch's archive first entry response has a domain of 'accounts.google.com'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{expires} eq '2014-04-03T22:13:46.000Z', "OUTPUT: HttpWatch's archive first entry response has a expires of '2014-04-03T22:13:46.000Z'");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{httpOnly}, "OUTPUT: HttpWatch's archive first entry response has httpOnly set to true");
ok($firebug_ref->{log}->{entries}->[0]->{response}->{cookies}->[0]->{secure}, "OUTPUT: HttpWatch's archive first entry response has secure set to true");
t/pingdom.t view on Meta::CPAN
use Test::More tests => 64;
use Archive::Har();
use JSON();
my $har = Archive::Har->new();
my $pingdom_string = '{"log":{"version":"1.2","creator":{"name":"Pingdom Tools","version":"","comment":"Test the load time of a web page at http://tools.pingdom.com/fpt"},"pages":[{"startedDateTime":"2012-03-23T01:22:05.820Z","id":"https://duckduckgo...
ok($har->string($pingdom_string), "Successfully read pingdom har archive for https://duckduckgo.com/?q=http+archive+specification");
ok($har->version() eq '1.2', "INPUT: Pingdom produces a version 1.2 http archive");
ok($har->creator()->name() eq 'Pingdom Tools', "INPUT: Pingdom's creator name is 'Pingdom Tools'");
ok($har->creator()->version() eq '', "INPUT: Pingdom's creator version is the empty string");
ok($har->creator()->comment() eq 'Test the load time of a web page at http://tools.pingdom.com/fpt', "INPUT: Pingdom's creator comment is advertising for Pingdom");
ok(scalar $har->pages() == 1, "INPUT: Pingdom's archive contains 1 page");
my ($firstPage) = $har->pages();
ok($firstPage->started_date_time() eq '2012-03-23T01:22:05.820Z', "INPUT: Pingdom's archive page has a startedDateTime of '2012-03-23T01:22:05.820Z'");
ok($firstPage->id() eq 'https://duckduckgo.com/?q=http+archive+specification', "INPUT: Pingdom's archive page has an id of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($firstPage->title() eq '', "INPUT: Pingdom's archive page has an empty string as the title");
ok($firstPage->page_timings()->on_content_load(-1) == 333, "INPUT: Pingdom's archive page has an onContentLoad of 333");
ok(not(defined $firstPage->page_timings()->on_content_load(undef)), "INPUT: Pingdom's archive page has an onContentLoad that is not defined (after being set to -1)");
ok(not(defined $firstPage->page_timings()->on_content_load(333)), "INPUT: Pingdom's archive page has an onContentLoad that is not defined (after being set to undef");
ok($firstPage->page_timings()->on_load(-1) == 372, "INPUT: Pingdom's archive page has an onLoad of 372");
ok(not(defined $firstPage->page_timings()->on_load(undef)), "INPUT: Pingdom's archive page has an onLoad that is not defined (after being set to -1)");
ok(not(defined $firstPage->page_timings()->on_load(372)), "INPUT: Pingdom's archive page has an onLoad that is not defined (after being set to undef)");
ok(scalar $har->entries() == 46, "INPUT: Pingdom's archive contains 46 entries");
my ($firstEntry) = $har->entries();
ok($firstEntry->pageref() eq 'https://duckduckgo.com/?q=http+archive+specification', "INPUT: Pingdom's archive first entry has a pageref of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($firstEntry->started_date_time() eq '2012-03-23T01:22:05.820Z', "INPUT: Pingdom's archive first entry has a startedDateTime of '2012-03-23T01:22:05.820Z'");
ok($firstEntry->time() == 173, "INPUT: Pingdom's archive first entry has a time of 173");
ok($firstEntry->request()->method() eq 'GET', "INPUT: Pingdom's archive first entry request has a method of 'GET'");
ok($firstEntry->request()->url() eq 'https://duckduckgo.com/?q=http+archive+specification', "INPUT: Pingdom's archive first entry request has a url of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($firstEntry->request()->http_version() eq 'HTTP/1.1', "INPUT: Pingdom's archive first entry request has a version of 'HTTP/1.1'");
ok(scalar $firstEntry->request()->cookies() == 0, "INPUT: Pingdom's archive first entry request has an empty cookie list");
ok(scalar $firstEntry->request()->headers() == 9, "INPUT: Pingdom's archive first entry request has 9 headers");
ok(scalar $firstEntry->timings()->blocked() == 0, "INPUT: Pingdom's archive first entry timings has a blocked value of 0");
ok(not(defined $firstEntry->timings()->dns()), "INPUT: Pingdom's archive first entry timings does not have a defined value for dns");
ok(scalar $firstEntry->timings()->connect() == 125, "INPUT: Pingdom's archive first entry timings has a connect value of 125");
ok(scalar $firstEntry->timings()->send() == 0, "INPUT: Pingdom's archive first entry timings has a send value of 0");
ok(scalar $firstEntry->timings()->wait() == 28, "INPUT: Pingdom's archive first entry timings has a wait value of 28");
ok(scalar $firstEntry->timings()->receive() == 1, "INPUT: Pingdom's archive first entry timings has a receive value of 1");
ok(scalar $firstEntry->timings()->ssl() == 19, "INPUT: Pingdom's archive first entry timings has a ssl value of 19");
$firstEntry->timings()->ssl(20);
ok($firstEntry->time() == 174, "INPUT: Pingdom's archive first entry has a time of 174 (after \$entry->timings()->ssl() was set to 20");
$firstEntry->timings()->ssl(19);
ok($firstEntry->time() == 173, "INPUT: Pingdom's archive first entry has a time of 173 (after \$entry->timings()->ssl() was reset to 19");
my $pingdom_ref = JSON::decode_json("$har");
ok($pingdom_ref->{log}->{version} eq '1.2', "OUTPUT: Pingdom produces a version 1.2 http archive");
ok($pingdom_ref->{log}->{creator}->{name} eq 'Pingdom Tools', "OUTPUT: Pingdom's creator name is 'Pingdom Tools'");
ok($pingdom_ref->{log}->{creator}->{version} eq '', "OUTPUT: Pingdom's creator version is the empty string");
ok($pingdom_ref->{log}->{creator}->{comment} eq 'Test the load time of a web page at http://tools.pingdom.com/fpt', "OUTPUT: Pingdom's creator comment is advertising for Pingdom");
ok(scalar @{$pingdom_ref->{log}->{pages}} == 1, "OUTPUT: Pingdom's archive contains 1 page");
ok($pingdom_ref->{log}->{pages}->[0]->{startedDateTime} eq '2012-03-23T01:22:05.820Z', "OUTPUT: Pingdom's archive page has a startedDateTime of '2012-03-23T01:22:05.820Z'");
ok($pingdom_ref->{log}->{pages}->[0]->{id} eq 'https://duckduckgo.com/?q=http+archive+specification', "OUTPUT: Pingdom's archive page has an id of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($pingdom_ref->{log}->{pages}->[0]->{title} eq '', "OUTPUT: Pingdom's archive page has an empty string as the title");
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onContentLoad} == 333, "OUTPUT: Pingdom's archive page has an onContentLoad of 333");
$firstPage->page_timings()->on_content_load(undef);
$pingdom_ref = $har->hashref();
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onContentLoad} == -1, "OUTPUT: Pingdom's archive page has an onContentLoad of -1 after being set to undef");
$firstPage->page_timings()->on_content_load('-1');
$pingdom_ref = $har->hashref();
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onContentLoad} == -1, "OUTPUT: Pingdom's archive page has an onContentLoad of -1 after being set to '-1'");
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onLoad} == 372, "OUTPUT: Pingdom's archive page has an onLoad of 372");
$firstPage->page_timings()->on_load(undef);
$pingdom_ref = $har->hashref();
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onContentLoad} == -1, "OUTPUT: Pingdom's archive page has an onContentLoad of -1 after being set to '-1'");
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onLoad} == -1, "OUTPUT: Pingdom's archive page has an onLoad of -1 after being set to undef");
$firstPage->page_timings()->on_load("-1");
$pingdom_ref = $har->hashref();
ok($pingdom_ref->{log}->{pages}->[0]->{pageTimings}->{onLoad} == -1, "OUTPUT: Pingdom's archive page has an onLoad of -1 after being set to '-1'");
ok(scalar @{$pingdom_ref->{log}->{entries}} == 46, "OUTPUT: Pingdom's archive contains 46 entries");
ok($pingdom_ref->{log}->{entries}->[0]->{pageref} eq 'https://duckduckgo.com/?q=http+archive+specification', "OUTPUT: Pingdom's archive first entry has a pageref of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($pingdom_ref->{log}->{entries}->[0]->{startedDateTime} eq '2012-03-23T01:22:05.820Z', "OUTPUT: Pingdom's archive first entry has a startedDateTime of '2012-03-23T01:22:05.820Z'");
ok($pingdom_ref->{log}->{entries}->[0]->{time} == 173, "OUTPUT: Pingdom's archive first entry has a time of 173");
ok($pingdom_ref->{log}->{entries}->[0]->{request}->{method} eq 'GET', "OUTPUT: Pingdom's archive first entry request has a method of 'GET'");
ok($pingdom_ref->{log}->{entries}->[0]->{request}->{url} eq 'https://duckduckgo.com/?q=http+archive+specification', "OUTPUT: Pingdom's archive first entry request has a url of 'https://duckduckgo.com/?q=http+archive+specification'");
ok($pingdom_ref->{log}->{entries}->[0]->{request}->{httpVersion} eq 'HTTP/1.1', "OUTPUT: Pingdom's archive first entry request has a httpVersion of 'HTTP/1.1'");
ok(scalar @{$pingdom_ref->{log}->{entries}->[0]->{request}->{cookies}} == 0, "OUTPUT: Pingdom's archive first entry request has an empty cookie list");
ok(scalar @{$pingdom_ref->{log}->{entries}->[0]->{request}->{headers}} == 9, "OUTPUT: Pingdom's archive first entry request has 9 headers");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{blocked} == 0, "OUTPUT: Pingdom's archive first entry timings has a blocked value of 0");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{dns} == -1, "OUTPUT: Pingdom's archive first entry timings has a dns value of -1");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{connect} == 125, "OUTPUT: Pingdom's archive first entry timings has a connect value of 125");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{send} == 0, "OUTPUT: Pingdom's archive first entry timings has a send value of 0");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{wait} == 28, "OUTPUT: Pingdom's archive first entry timings has a wait value of 28");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{receive} == 1, "OUTPUT: Pingdom's archive first entry timings has a receive value of 1");
ok($pingdom_ref->{log}->{entries}->[0]->{timings}->{ssl} == 19, "OUTPUT: Pingdom's archive first entry timings has a ssl value of 19");
( run in 0.380 second using v1.01-cache-2.11-cpan-4e96b696675 )