File: tests/manually/HttpClientHeadTestManually.php

Recommend this page to a friend!
  Classes of Maik Greubel  >  PHP Generics  >  tests/manually/HttpClientHeadTestManually.php  >  Download  
File: tests/manually/HttpClientHeadTestManually.php
Role: Unit test script
Content type: text/plain
Description: Manually test the http client header retrieval
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change:
Date: 5 years ago
Size: 625 bytes
 

Contents

Class file image Download
<?php
set_include_path
(get_include_path() . PATH_SEPARATOR . '../../');

require_once
'vendor/autoload.php';

use
Generics\Client\HttpClient;
use
Generics\Socket\Url;

$http = new HttpClient(new Url('httpbin.org', 80));
$http->request('HEAD');

if (
$http->getResponseCode() == 200) {
   
$response = "";

    while (
$http->getPayload()->ready()) {
       
$response = $http->getPayload()->read(
           
$http->getPayload()->count()
        );
    }

    foreach (
$http->getHeaders() as $headerName => $headerValue) {
       
printf("%s: %s\n", $headerName, $headerValue);
    }
   
printf("Response: %s\n", $response);
}


For more information send a message to info at phpclasses dot org.