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

Commit

Permalink
fix(server): Add missing setting for "package_max_length" (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
fjogeleit authored and k911 committed Dec 19, 2019
1 parent 75e7f23 commit 37758f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/configuration-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,7 @@ swoole:

buffer_output_size: 2097152
# in bytes, 2097152b = 2 MiB

package_max_length: 8388608
# in bytes, 8388608b = 8 MiB
```
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ public function getConfigTreeBuilder(): TreeBuilder
->scalarNode('buffer_output_size')
->defaultValue(2097152)
->end()
->scalarNode('package_max_length')
->defaultValue(8388608)
->end()
->integerNode('worker_count')
->min(1)
->end()
Expand Down
8 changes: 8 additions & 0 deletions src/Server/HttpServerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class HttpServerConfiguration
private const SWOOLE_HTTP_SERVER_CONFIG_LOG_LEVEL = 'log_level';
private const SWOOLE_HTTP_SERVER_CONFIG_PID_FILE = 'pid_file';
private const SWOOLE_HTTP_SERVER_CONFIG_BUFFER_OUTPUT_SIZE = 'buffer_output_size';
private const SWOOLE_HTTP_SERVER_CONFIG_PACKAGE_MAX_LENGTH = 'package_max_length';

/**
* @todo add more
Expand All @@ -41,6 +42,7 @@ class HttpServerConfiguration
self::SWOOLE_HTTP_SERVER_CONFIG_LOG_LEVEL => 'log_level',
self::SWOOLE_HTTP_SERVER_CONFIG_PID_FILE => 'pid_file',
self::SWOOLE_HTTP_SERVER_CONFIG_BUFFER_OUTPUT_SIZE => 'buffer_output_size',
self::SWOOLE_HTTP_SERVER_CONFIG_PACKAGE_MAX_LENGTH => 'package_max_length',
self::SWOOLE_HTTP_SERVER_CONFIG_TASK_WORKER_COUNT => 'task_worker_num',
];

Expand Down Expand Up @@ -71,6 +73,7 @@ class HttpServerConfiguration
* - serve_static_files (default: false)
* - public_dir (default: '%kernel.root_dir%/public')
* - buffer_output_size (default: '2097152' unit in byte (2MB))
* - package_max_length (default: '8388608b' unit in byte (8MB))
*
* @throws \Assert\AssertionFailedException
*/
Expand Down Expand Up @@ -333,6 +336,11 @@ private function validateSetting(string $key, $value): void
case self::SWOOLE_HTTP_SERVER_CONFIG_LOG_LEVEL:
Assertion::inArray($value, \array_keys(self::SWOOLE_LOG_LEVELS));

break;
case self::SWOOLE_HTTP_SERVER_CONFIG_PACKAGE_MAX_LENGTH:
Assertion::integer($value, \sprintf('Setting "%s" must be an integer.', $key));
Assertion::greaterThan($value, 0, 'Package max length value cannot be negative or zero, "%s" provided.');

break;
case self::SWOOLE_HTTP_SERVER_CONFIG_BUFFER_OUTPUT_SIZE:
Assertion::integer($value, \sprintf('Setting "%s" must be an integer.', $key));
Expand Down

0 comments on commit 37758f2

Please sign in to comment.