Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2020-12-06 (10 days ago) | | Not yet rated by the users | | Total: 43 This week: 8 | | All time: 9,958 This week: 28 |
|
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. | |
|
|
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());
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.