-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
up: update some for client config and tests
- Loading branch information
Showing
21 changed files
with
298 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use PhpComp\Http\Client\Client; | ||
use PhpComp\Http\Client\ClientConst; | ||
use PhpComp\Http\Client\Swoole\CoClient; | ||
|
||
require dirname(__DIR__) . '/test/bootstrap.php'; | ||
|
||
$client = Client::factory([ | ||
'driver' => CoClient::driverName(), | ||
]); | ||
$client->setUserAgent(ClientConst::USERAGENT_CURL); | ||
|
||
// debug | ||
// $client->setDebug(true); | ||
// $client->setOption('logFile', './client-req.log'); | ||
|
||
$client->get('https://cht.sh/php/array_shift'); | ||
|
||
vdump( | ||
$client->getDriverName(), | ||
$client->getResponseHeaders() | ||
); | ||
|
||
echo $client->getResponseBody(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
use PhpComp\Http\Client\Client; | ||
use PhpComp\Http\Client\ClientConst; | ||
|
||
require dirname(__DIR__) . '/test/bootstrap.php'; | ||
|
||
$client = Client::factory([]); | ||
$client->setUserAgent(ClientConst::USERAGENT_CURL); | ||
|
||
// debug | ||
// $client->setDebug(true); | ||
// $client->setOption('logFile', './client-req.log'); | ||
|
||
$client->get('https://cht.sh/php/array_shift'); | ||
|
||
vdump( | ||
$client->getDriverName(), | ||
$client->getResponseHeaders() | ||
); | ||
|
||
echo $client->getResponseBody(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace PhpComp\Http\Client; | ||
|
||
/** | ||
* Class ClientConst | ||
* | ||
* @package PhpComp\Http\Client | ||
*/ | ||
class ClientConst | ||
{ | ||
public const HTML = 'text/html'; | ||
public const JSON = 'application/json'; | ||
public const XML = 'application/xml'; | ||
|
||
public const MULTIPART = 'multipart/form-data'; | ||
|
||
public const USERAGENT_CURL = 'CURL/7.64.1'; | ||
|
||
public const USERAGENT_BROWSER = 'Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3121 MMWEBSDK/201201 Mobile Safari/537.36 MMWEBID/356 MicroMessenger/8.0.1.1841(0x2800015D) Process/appbrand2 WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android'; | ||
} |
Oops, something went wrong.