Swoole-src: Http\Response->status 请求http status code 放开允许用户自己设置

Created on 22 Oct 2019  ·  3Comments  ·  Source: swoole/swoole-src

以前业务用laravel框架写的有 自定义http status code状态 如480其他等 现在想swoole提升性能
但状态码无法自定义 是一个很大限制 请求放开
地址:https://wiki.swoole.com/wiki/page/338.html

question

Most helpful comment

use Swoole\Http\Request;
use Swoole\Http\Response;

$http = new \Swoole\Http\Server('127.0.0.1', 9501);
$http->on('request', function (Request $request, Response $response) {
    $response->status(999, 'Swoole');
    $response->end();
});
$http->start();

image

文档已更新

All 3 comments

@erDong01 你这个状态码480不能从返回的数据里面得到吗?我理解的是你们自己业务定义的一个状态码,而不是http协议里面的那个。

@huanghantao 是的 是我们自己根据自己的业务定义的一个状态码 不在http协议里。我们前期开发的业务已经跟前端约定了 返回放在了 http status code 没放在body里面 SwooleHttpResponse->status(int $http_status_code);限制了状态码 这里个人浏览器都支持了觉得swoole也不要限制了吧 毕竟不同用户有不用开发需求

use Swoole\Http\Request;
use Swoole\Http\Response;

$http = new \Swoole\Http\Server('127.0.0.1', 9501);
$http->on('request', function (Request $request, Response $response) {
    $response->status(999, 'Swoole');
    $response->end();
});
$http->start();

image

文档已更新

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daslicht picture daslicht  ·  4Comments

jobs-git picture jobs-git  ·  3Comments

sshymko picture sshymko  ·  3Comments

pthreat picture pthreat  ·  3Comments

onanying picture onanying  ·  3Comments