Skip to content

Commit 088b02b

Browse files
committed
Make sure we can opt-in on capturing body
1 parent 58bcf5b commit 088b02b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Collector/Twig/HttpMessageMarkupExtension.php

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public function markup($message)
3232
return $safeMessage;
3333
}
3434

35+
if (empty($parts[1])) {
36+
$parts[1] = '(This message has no captured body)';
37+
}
38+
3539
// make header names bold
3640
$headers = preg_replace("|\n(.*?): |si", "\n<b>$1</b>: ", $parts[0]);
3741

DependencyInjection/Configuration.php

+5
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ public function getConfigTreeBuilder()
8383
->defaultValue('auto')
8484
->end()
8585
->scalarNode('formatter')->defaultNull()->end()
86+
->scalarNode('captured_body_length')
87+
->defaultValue(0)
88+
->canNotBeEmpty()
89+
->info('Limit long HTTP message bodies to x characters. If set to 0 we do not read the message body. Only available with the default formatter (FullHttpMessageFormatter).')
90+
->end()
8691
->end()
8792
->end()
8893
->end();

DependencyInjection/HttplugExtension.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ public function load(array $configs, ContainerBuilder $container)
4343
$config['_inject_collector_plugin'] = true;
4444

4545
if (!empty($config['toolbar']['formatter'])) {
46-
$container->getDefinition('httplug.collector.message_journal')
46+
// Add custom formatter
47+
$container->getDefinition('httplug.collector.debug_collector')
4748
->replaceArgument(0, new Reference($config['toolbar']['formatter']));
4849
}
50+
51+
$container->getDefinition('httplug.formatter.full_http_message')
52+
->addArgument($config['toolbar']['captured_body_length']);
4953
}
5054

5155
foreach ($config['classes'] as $service => $class) {

0 commit comments

Comments
 (0)