File: tests/manually/HttpClientTestManually.php

Recommend this page to a friend!
  Classes of Maik Greubel  >  PHP Generics  >  tests/manually/HttpClientTestManually.php  >  Download  
File: tests/manually/HttpClientTestManually.php
Role: Unit test script
Content type: text/plain
Description: Unit test for manually testing HttpClientSocket
Class: PHP Generics
Framework for accessing streams, sockets and logs
Author: By
Last change: Working on test code coverage and fixing
Fix HttpClient, change toString behaviour in FIS and FOS, add
Http-Head-Test for manual testing and debugging
Better Url parsing and handling
Date: 5 years ago
Size: 650 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('GET');

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);

   
$http->disconnect();
}


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