<commit_before>#!/usr/bin/env php
<?php
include_once __DIR__ . '/../common.php';
use Gaia\Test\Tap;
use Gaia\Http\Request;

if( ! @fsockopen('github.com', 443) ){
    Tap::plan('skip_all', 'unable to connect to remote host for test');
}

Tap::plan(7);

$request = new Request('https://github.com/gaiaops/gaia_core_php');
$start = microtime(TRUE);
$response = $request->exec();
$elapsed = number_format( microtime(TRUE) - $start, 5);
Tap::is( $response->http_code, '200', 'got back a 200 response');
Tap::cmp_ok($response->size_download, '>', 0, 'got back content');
Tap::cmp_ok($response->speed_download, '>', 0, 'measured how long it took');
Tap::cmp_ok( $diff = number_format(abs( $elapsed - $response->total_time), 4), '<', 0.01, 'total_time measured matches expectations: '. $diff );
Tap::like( $response->request_header, '#GET /gaiaops/gaia_core_php HTTP/1.1#i', 'request header sent to the correct url');
Tap::like( $response->body, '/gaia_core_php hosted on GitHub/i', 'got back the correct content');
Tap::is( $response->headers->Connection, 'keep-alive', 'sent a keep-alive header and got back a keep-alive response');
unset( $response->body );
//print_r( $response );
<commit_msg>adding a test for http<commit_after>#!/usr/bin/env php
<?php
include_once __DIR__ . '/../common.php';
use Gaia\Test\Tap;
use Gaia\Http\Request;

if( ! @fsockopen('github.com', 443) ){
    Tap::plan('skip_all', 'unable to connect to remote host for test');
}

Tap::plan(7);

$request = new Request('https://github.com/gaiaops/gaia_core_php');
$start = microtime(TRUE);
$response = $request->exec();
$elapsed = number_format( microtime(TRUE) - $start, 5);
Tap::is( $response->http_code, '200', 'got back a 200 response');
Tap::cmp_ok($response->size_download, '>', 0, 'got back content');
Tap::cmp_ok($response->speed_download, '>', 0, 'measured how long it took');
Tap::cmp_ok( $diff = number_format(abs( $elapsed - $response->total_time), 4), '<', 0.01, 'total_time measured matches expectations: '. $diff );
Tap::like( $response->request_header, '#GET /gaiaops/gaia_core_php HTTP/1.1#i', 'request header sent to the correct url');
Tap::like( $response->body, '/gaia_core_php hosted on GitHub/i', 'got back the correct content');
Tap::is( $response->headers->Connection, 'keep-alive', 'sent a keep-alive header and got back a keep-alive response');
Tap::is( strlen( $response->body ), $response->headers->{'Content-Length'}, 'got back expected amount of content');
unset( $response->body );
//print_r( $response );

{'fraction_non_alphanumeric': 0.19321357285429142, 'fraction_numerical': 0.015169660678642715, 'mean_word_length': 5.736559139784946, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5963310', 'n_tokens_mistral': 902, 'n_tokens_neox': 867, 'n_words': 228}