Skip to content

Server Facade #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 10, 2017
Merged

Server Facade #271

merged 1 commit into from
Dec 10, 2017

Conversation

WyriHaximus
Copy link
Member

@WyriHaximus WyriHaximus commented Dec 3, 2017

Follow up on #266 reintroducing the Server class but this time as a facade around StreamingServer.

  • Documentation
  • Tests

Closes #259

@WyriHaximus
Copy link
Member Author

Ping @clue && @jsor the first bit of documentation is in.

@WyriHaximus
Copy link
Member Author

Ping @clue new middleware is included in the Server facade now. Decided to go with a strategy that bases the amount of concurrently handled requests on the memory limit and post size limit.

src/Server.php Outdated
* Wraps StreamingServer with the following middleware:
* - RequestBodyBufferMiddleware
* - RequestBodyParserMiddleware
* - The callable you in passed as first constructor argument
Copy link
Member

Choose a reason for hiding this comment

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

LimitConcurrentRequestsMiddleware missing now here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed that 👍

@WyriHaximus
Copy link
Member Author

Added documentation to the readme

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

Good job, I really like the direction this is heading! 👍 I think this will need a major documentation overhaul, but this is definitely a very good first step! 👍

* - upload_max_filesize
* - post_max_size
* - max_input_nesting_level
* - max_input_vars
Copy link
Member

Choose a reason for hiding this comment

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

This also respects file_uploads and max_file_uploads ini settings as documented for RequestBodyParserMiddleware.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah my bad, added them 👍

src/Server.php Outdated
* Wraps StreamingServer with the following middleware:
* - LimitConcurrentRequestsMiddleware
* - RequestBodyBufferMiddleware
* - RequestBodyParserMiddleware
Copy link
Member

Choose a reason for hiding this comment

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

What about the enable_post_data_reading ini setting as documented for RequestBodyParserMiddleware? Arguably, we may want to remove the RequestBodyParserMiddleware from the middleware list in this case to mimic PHP's default behavior?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the PR to respect enable_post_data_reading

WyriHaximus added a commit to WyriHaximus/http that referenced this pull request Dec 9, 2017
WyriHaximus added a commit to WyriHaximus/http that referenced this pull request Dec 9, 2017
src/Server.php Outdated
$middleware = array();
$middleware[] = new LimitConcurrentRequestsMiddleware($this->getConcurrentRequestsLimit());
$middleware[] = new RequestBodyBufferMiddleware();
if (ini_get('enable_post_data_reading')) {
Copy link
Member

Choose a reason for hiding this comment

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

This fails with HHVM and legacy PHP < 5.4: https://3v4l.org/qJtsa

$ php -d enable_post_data_reading=no -r 'var_dump(ini_get("enable_post_data_reading"));'
string(0) ""

Accordingly, this should probably check for !== '' instead? Also, can you add a comment for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm interesting, but what happens then when set to 0?

Copy link
Member

@clue clue Dec 9, 2017

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the check

@WyriHaximus WyriHaximus changed the title [WIP] Server Facade Server Facade Dec 10, 2017
WyriHaximus added a commit to WyriHaximus/http that referenced this pull request Dec 10, 2017
WyriHaximus added a commit to WyriHaximus/http that referenced this pull request Dec 10, 2017
Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

Functionally LGTM and would love to get this in :shipit: Can you fix the failing tests and squash this to a reasonable number of commits? 👍

@WyriHaximus
Copy link
Member Author

@clue fixed the test and squashed the commits

Copy link
Member

@clue clue left a comment

Choose a reason for hiding this comment

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

LGTM :shipit: 👍

src/Server.php Outdated
*/
final class Server
{
const MAXIMUM_CONCURRENT_REQUESTS = 100;
Copy link
Member

Choose a reason for hiding this comment

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

Minor nitpick: Should probably be @internal 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, added that 👍

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

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy