Comments (5)
这是说Header已经被发送过了,或者之前已经有输出了,不确定是否是Swoole会默认输出什么东西?
from yar.
PHP_METHOD(yar_server, handle)
{
if (SG(headers_sent)) {
php_error_docref(NULL, E_WARNING, "headers already has been sent");
RETURN_FALSE;
@matyhtf 有没有可能swoole在一个请求结束后,没有重置这个SG(headers_sent)标志?
from yar.
@laruence 由于 swoole 是并发服务器,没有SG(headers_sent)
全局变量的概念。状态是绑定在Request
和Response
对象上的。请求响应的处理不会设置SG(headers_sent)
全局变量状态。只有局部变量,没有任何全局变量。
在 swoole 中也无法使用 PHP 的header()
、setcookie()
等函数
想不到太好的解决办法,这里应该有好几个地方不兼容。
<?php
$http = new swoole_http_server("127.0.0.1", 9501);
$http->on("start", function ($server) {
echo "Swoole http server is started at http://127.0.0.1:9501 \n";
});
$http->on("request", function ($request, $response) {
$response->header("Content-Type", "text/plain");
$response->cookie("test", "value", time() + 3600);
var_dump($requset->get, $requset->post, $request->cookie);
$response->end("Hello World\n");
});
$http->start();
from yar.
如果要兼容 swoole 或者 workerman 这样的服务器,yar 需要提供设置自定义 header、setcookie 的 API
from yar.
hmm, 看起来没那么简单,不过在swoole场景下,还要yar干嘛呢?或者就不http了?
from yar.
Related Issues (20)
- 多次并行调用导致内存泄露 HOT 4
- Header头Hostname传递非法字符串导致Go-Yar服务返回400错误 HOT 2
- 自定义异常包含析构函数无法正常在client捕捉 HOT 1
- $callinfo的属性具体有哪些? HOT 1
- 客户端调用服务端,500错误,请看日志 HOT 3
- 服务端地址页面底部 多出来的信息是哪里来的? HOT 2
- yar 502 HOT 2
- rpc server请求连接池 和 权重动态调整 如何实现? HOT 2
- header中的provider和token可否自定义 HOT 1
- php8兼容性问题 HOT 1
- Wrong link to source code in PECL website HOT 1
- yar.go中调用yar报错need specifical request method HOT 3
- http2.0协议支持
- mac book pro M1 is not working properly HOT 2
- need specifical request method HOT 2
- tests/047.phpt erratic results HOT 4
- yar 400 HOT 1
- Yar Server页面无法正常展示 HOT 3
- 服务端如何捕获异常?有没有统一的办法?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yar.