Archive-Har

 view release on metacpan or  search on metacpan

t/firebug_post.t  view on Meta::CPAN

            {
              "name": "Content-Type",
              "value": "application/x-javascript; charset=UTF-8"
            },
            {
              "name": "Transfer-Encoding",
              "value": "chunked"
            },
            {
              "name": "Connection",
              "value": "keep-alive"
            },
            {
              "name": "Expires",
              "value": "Fri, 23 Mar 2012 05:27:54 GMT"
            },
            {
              "name": "Cache-Control",
              "value": "no-cache"
            },
            {
              "name": "Content-Encoding",
              "value": "gzip"
            }
          ],
          "content": {
            "mimeType": "application/x-javascript",
            "size": 225,
            "text": "if (nrq) nrq([{\"r\":\"\",\"s\":\"files\"},{\"r\":\"\",\"s\":\"compression\"},{\"r\":\"\",\"s\":\"please\"},{\"r\":\"\",\"s\":\"javascript\"},{\"r\":\"\",\"s\":\"version\"},{\"r\":\"\",\"s\":\"string\"},{\"r\":\"\",\"s\":\"submit...
          },
          "redirectURL": "",
          "headersSize": 267,
          "bodySize": 126
        },
        "cache": {},
        "timings": {
          "blocked": 1,
          "dns": 0,
          "connect": 910,
          "send": 0,
          "wait": 419,
          "receive": 0
        },
        "serverIPAddress": "176.34.131.233",
        "connection": "443"
      }
    ]
  }
}
_FIREBUG_RESULTS_
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'");



( run in 0.494 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )