PHP Classes

PHP HTTP Agent: Extensible HTTP client with a fluent interface

Recommend this page to a friend!
  Info   View files Documentation   View files View files (25)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-12-06 (11 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 62 All time: 9,988 This week: 393Up
Version License PHP version Categories
httpagent 1.0.0MIT/X Consortium ...5HTTP, PHP 5
Description Author

This package provides an extensible HTTP client with a fluent interface.

It can define and send HTTP requests to remote servers using a fluent interface to setup several types of parameters like the request URL, method, headers, form input values, etc..

The package can also assign a callback function that is called to handle the server response data returned by the server.

Picture of Payam Naderi
  Performance   Level  
Name: Payam Naderi <contact>
Classes: 15 packages by
Country: United States United States
Age: 38
All time rank: 2082288 in United States United States
Week rank: 895 Up93 in United States United States Up
Innovation award
Innovation award
Nominee: 2x

Details

HttpAgent

$browser = new Browser('http://192.168.123.171/', [
    'request' => [
        'headers' => [
            'Accept' => 'application/json, text/javascript, /; q=0.01',
        ]
    ]
]);

$result = $browser->POST('/api/v1/auth/login'
    , [ 'form_data'
        => [
            'email'    => 'naderi.payam@gmail.com',
            'password' => '123456'
        ]
    ]
);

$result->expected(function(HttpResponse $httpResponse) use ($browser) {
    $jsonResult = $httpResponse->plg()->json();
    $authHeader = HeaderFactory::factory('Authorization', 'Bearer '.$jsonResult->token);
    $browser->inOptions()->getRequest()->getHeaders()->set(
        $authHeader
    );
});

$browser->GET('/api/v1/users/me', null, [
    'Accept' => 'application/json, text/javascript, /; q=0.01',
    'X-Requested-With' => 'XMLHttpRequest',
    'Referer' => 'http://localhost:8080/'
])->expected(function($response) {
    $response->flush(false);
});

$request =
        "GET /payam/ HTTP/1.1\r\n"
        ."Host: 95.211.189.240\r\n"
        ."User-Agent: AranRojan-PHP/5.5.9-1ubuntu4.11\r\n"
        ."Accept-Encoding: gzip\r\n"
        ."Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8\r\n"
        ."Cache-Control: no-cache"
    ;
    $browser = new Browser('http://95.211.189.240/', ['connection' => ['allow_decoding' => false]]);
    $res = $browser->request(new HttpRequest($request));

    echo ($res->getRawBody()->read());
  Files folder image Files  
File Role Description
Files folder imageInterfaces (1 file, 1 directory)
Files folder imagePlatform (3 files, 1 directory)
Files folder imageTransporter (4 files, 1 directory)
Plain text file Browser.php Class Class source
Plain text file CommandRequestHttp.php Class Class source
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  Interfaces  
File Role Description
Files folder imageBrowser (3 files)
  Plain text file iTransporterHttp.php Class Class source

  Files folder image Files  /  Interfaces  /  Browser  
File Role Description
  Plain text file iPluginBrowser.php Class Class source
  Plain text file iPluginBrowserExpression.php Class Class source
  Plain text file iPluginBrowserResponse.php Class Class source

  Files folder image Files  /  Platform  
File Role Description
Files folder imagePlugin (6 files)
  Plain text file PlatformHttp.php Class Class source
  Plain text file PluginsOfBrowser.php Class Class source
  Plain text file ResponsePlatform.php Class Class source

  Files folder image Files  /  Platform  /  Plugin  
File Role Description
  Plain text file BaseBrowserPlugin.php Class Class source
  Plain text file CookieBrowserPlg.php Class Class source
  Plain text file PluginFormData.php Class Class source
  Plain text file PluginFormUrlEncodeData.php Class Class source
  Plain text file PluginJsonData.php Class Class source
  Plain text file ServiceAggregate.php Class Class source

  Files folder image Files  /  Transporter  
File Role Description
Files folder imageListeners (4 files)
  Plain text file DataCollectorEventOfTransporterHttp.php Class Class source
  Plain text file EventHeapTransporterHttp.php Class Class source
  Plain text file TransporterHttpOptions.php Class Class source
  Plain text file TransporterHttpSocket.php Class Class source

  Files folder image Files  /  Transporter  /  Listeners  
File Role Description
  Plain text file onRequestPrepareExpression.php Class Class source
  Plain text file onResponseHeadersReceived.php Class Class source
  Plain text file onResponseReceived.php Class Class source
  Plain text file onResponseReceivedCloseConnection.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:9,988
This week:393Up
For more information send a message to info at phpclasses dot org.