-
-
Notifications
You must be signed in to change notification settings - Fork 46
Allow to prepare response outside of Request #40
Conversation
Hi! This change required to receive body data for PSR-7 response passing (not echo).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea itself is OK but it is possible to make API better.
*/ | ||
public function send() | ||
public function send($return = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we have send()
that does not send. :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about getData(): string
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a little confusing. Technically you send it but not in stdout but to the variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like with print_r function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also logically it suppose to call events that you already have in send() when i requesting filled response...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha. Then maybe process()
that returns data? Then send()
will look like echo process()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samdark that can work. What about events EVENT_BEFORE_SEND
and EVENT_AFTER_SEND
? Technically we sending content somewhere. Or these events apply only to stdout print?
I found $response->on(Response::EVENT_AFTER_SEND, [$this, 'cacheResponse']);
in PageCache. If we dont call it when we working with RR cache will be newer generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually PageCache will never work with PSR-7 server. It requesting data from ob_get_clean()
which always will be empty. Or we rewrite it so it will collect data from Response
, not ob_get_clean()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sending events should be called for sending only. We can add two additional events for processing. Roadrunner-like server and traditional server are two similar but different models so there may be need to do things a bit differently.
Goind to implement proper PSR usage. |
Hi!
This change required to receive body data for PSR-7 response passing (not echo).