- 授权协议: MIT
- 开发语言: PHP
- 操作系统: 跨平台
- 软件首页: https://github.com/toohamster/ws-http
- 软件文档: http://my.oschina.net/vb2005xu/blog/724044
软件介绍
ws-http:简单轻量的HTTP 客户端工具库。
可用于 HTTP API 测试,支持 ssl,basic auth,代理,自定义请求头,以及常用HTTP 请求方法。
$httpRequest = \Ws\Http\Request::create();
$httpResponse = $httpRequest->get("https://api.github.com");
$watcher = \Ws\Http\Watcher::create($httpResponse);
$watcher
->assertStatusCode(200)
->assertHeadersExist(array(
"X-GitHub-Request-Id",
"ETag"
))
->assertHeaders(array(
"Server" => "GitHub.com"
))
->assertBody('IS_VALID_JSON')
->assertTotalTimeLessThan(2);
$httpRequest = \Ws\Http\Request::create();
$httpResponse = $httpRequest->get("https://freegeoip.net/json/8.8.8.8");
$watcher = \Ws\Http\Watcher::create($httpResponse);
$watcher
->assertStatusCode(200)
->assertHeadersExist(array(
"Content-Length"
))
->assertHeaders(array(
"Access-Control-Allow-Origin" => "*"
))
->assertBodyJsonFile(dirname(__DIR__) . "/tests/Ws/Http/_json/freegeoip.net.json");
查看所有例子: https://github.com/toohamster/ws-http/blob/master/tests/Ws/Http/ATest.php.
要求:
-
PHP:版本 5.4.40 以上
-
PHP Extensions:Curl
