fgsl/http

Fgsl Http Requester

维护者

详细信息

github.com/fgsl/http

主页

源代码

问题

安装: 129

依赖者: 3

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

开放问题: 1

类型:组件

1.4.1 2023-06-15 17:54 UTC

This package is auto-updated.

Last update: 2024-09-15 20:16:53 UTC


README

composer require fgsl/http

运行命令

composer install

获取Composer: https://getcomposer.org.cn/download/

运行单元测试

phpunit --bootstrap tests/bootstrap.php tests/Fgsl/Test/TestSuite.php

如何使用

下面是方法 request 的一个示例。

use Fgsl\Http\Http;

$ctx = Http::getContext('GET', null);
@$response = Http::request("http://www.horalegalbrasil.mct.on.br/SincronismoPublico.html", $ctx);
        
$this->assertStringContainsString('Sincronismo', $response);

变量 $ctx 接收一个 HTTP 上下文,即包含 HTTP 协议元素的资源。

变量 $response 接收根据 $ctx 定义的上下文下的 HTTP 响应文本。

有时方法 request 可能无法正常工作。这时你可以使用方法 curl

查看ApiTest 类获取更多示例。