Comments (10)
But sorry, at first, I don't prefer __toString for Render for PSR-7
. 😠
(reason is wrote at http://sasezaki.hatenablog.com/entry/2015/03/07/195908 )
from bear.middleware.
Agreed. Handler should be handle stream not body string.
Your code seems works fine. Would you send PR ?
https://gist.github.com/sasezaki/68670975fbb5ca5114ed
Then we can leave your contribution on repository.
Or I can fixed it later. Thank you for making the issue.
from bear.middleware.
ok. I would try at this weekend.
from bear.middleware.
Awesome !
from bear.middleware.
sorry for late. I couldn't take a time to catch up lack of BEAR.Sunday knowledge.
so I want someone working on this.
from bear.middleware.
no problem, I will do it later with your code.
from bear.middleware.
quick fix for header now.
from bear.middleware.
ResourceObject should be render (__toString) before looking up headers
Fixed !
But sorry, at first, I don't prefer __toString for Render for PSR-7. 😠
Now RequestHandler
returns 100% genuine stream response.
But things are not easy as first glance. The current implementation has limitation. This version can't handle with your blog post example. (view template produce huge text).
Instead, we can assign stream
resource at ResourceObject
public function onGet()
{
$this['msg'] = 'hello world';
$this['stream'] = fopen(__DIR__ . '/message.txt', 'r');
return $this;
}
hello world
text and /message.txt
stream are placed at their place folder in layout file, then text parts(hello world and layout template) is converted to stream to merge native stream (message.txt). You can assign multiple stream in any place. All stream will be merged and streamed.
https://github.com/bearsunday/BEAR.Middleware/blob/1.x/src/Module/StreamRenderer.php#L117
If you want single stream without any fixed text, you simple assign stream to entire resource body.
public function onGet()
{
$this->body = fopen(__DIR__ . '/message.txt', 'r');
return $this;
}
from bear.middleware.
@sasezaki I tested with huge text stream, It succeeded but need to change output procedure as you mentioned.
from bear.middleware.
@sasezaki your blog post are SUPER helpful. (I knew very little about it)
Huge thanks !!
from bear.middleware.
Related Issues (2)
- PSR7 stream output HOT 1
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 bear.middleware.