Skip to content

Commit 019a2ea

Browse files
authored
Merge pull request #432 from Raidri/patch-1
[FEATURE] Optimize max header size handling
2 parents f2fb393 + 4d7b034 commit 019a2ea

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Classes/Generator/HtaccessGenerator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,16 @@ public function generate(GeneratorCreate $generatorCreateEvent): void
4949

5050
protected function cleanupHeaderValues(array $headers): array
5151
{
52+
$configurationService = $this->getConfigurationService();
53+
$maxHeaderSize = (int)($configurationService->get('maxHeaderSize') ?? 8192);
54+
$headerSizeBuffer = (float)($configurationService->get('headerSizeBuffer') ?? 0);
55+
56+
if($headerSizeBuffer > 0){
57+
$maxHeaderSize = (int)($maxHeaderSize / $headerSizeBuffer);
58+
}
5259
// respect max length
5360
foreach ($headers as $key => $value) {
54-
$headers[$key] = substr((string) $value, 0, 1024 * 8); // 8K Max header for Apache
61+
$headers[$key] = substr((string) $value, 0, $maxHeaderSize); // 8K Max header for Apache
5562
}
5663

5764
// illegal chars

ext_conf_template.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ overrideClientUserAgent =
1313
# cat=basic; type=boolean; label=Debug headers: Send debug headers to get a information which component deliver the file (X-SFC-State).
1414
debugHeaders = 0
1515

16+
# cat=basic; type=int+; label=The maximum allowed header size from your apache / nginx / webserver configuration
17+
maxHeaderSize = 8192
18+
19+
# cat=basic; type=string; label=Reduce the maxHeaderSize with this buffer to keep space if you would reach the maxHeaderSize
20+
headerSizeBuffer = 1.5
21+
1622
# cat=basic; type=string; label=Valid .htaccess headers: List of headers that are transferred to the .htaccess configuration. E.g. if you use config.additionalHeaders.xxx you can add this headers here. Please change this configuration only, if you know what you do. "Content-Type" is recommended. Note: Content-Type will be added automatically.
1723
validHtaccessHeaders = Content-Type,Content-Language,Content-Security-Policy,Link,X-SFC-Tags
1824

0 commit comments

Comments
 (0)