Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Allow to prepare response outside of Request #40

Closed
wants to merge 2 commits into from

Conversation

Alex-Bond
Copy link

Hi!

This change required to receive body data for PSR-7 response passing (not echo).

Q A
Is bugfix? no
New feature? yes
Breaks BC? no
Tests pass? yes
Fixed issues none

Hi!

This change required to receive body data for PSR-7 response passing (not echo).
Copy link
Member

@samdark samdark left a 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.

src/Response.php Outdated Show resolved Hide resolved
*/
public function send()
public function send($return = false)
Copy link
Contributor

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

Copy link
Member

@samdark samdark Jan 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about getData(): string?

Copy link
Author

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.

Copy link
Author

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.

Copy link
Author

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...

Copy link
Member

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().

Copy link
Author

@Alex-Bond Alex-Bond Jan 12, 2019

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.

Copy link
Author

@Alex-Bond Alex-Bond Jan 12, 2019

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().

Copy link
Member

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.

@samdark
Copy link
Member

samdark commented Jan 16, 2019

#11

@samdark samdark closed this Mar 12, 2019
@samdark
Copy link
Member

samdark commented Mar 12, 2019

Goind to implement proper PSR usage.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants