Skip to content

Commit 65d4471

Browse files
committed
WIP configure seekable body plugin
1 parent b587fb4 commit 65d4471

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,32 @@ private function createClientPluginNode()
414414
->end()
415415
->end()
416416
->end()
417+
->arrayNode('request_seekable_body')
418+
->canBeEnabled()
419+
->info('Ensure that the request body is seekable so that several plugins can look into it.')
420+
->children()
421+
->booleanNode('use_file_buffer')
422+
->info('Whether to use a file buffer if the stream is too big for a memory buffer')
423+
->defaultTrue()
424+
->end()
425+
->scalarNode('memory_buffer_size')
426+
->info('Maximum memory size in bytes before using a file buffer if use_file_buffer is true. Defaults to 2 MB')
427+
->end()
428+
->end()
429+
->end()
430+
->arrayNode('response_seekable_body')
431+
->canBeEnabled()
432+
->info('Ensure that the response body is seekable so that several plugins can look into it.')
433+
->children()
434+
->booleanNode('use_file_buffer')
435+
->info('Whether to use a file buffer if the stream is too big for a memory buffer')
436+
->defaultTrue()
437+
->end()
438+
->scalarNode('memory_buffer_size')
439+
->info('Maximum memory size in bytes before using a file buffer if use_file_buffer is true. Defaults to 2 MB')
440+
->end()
441+
->end()
442+
->end()
417443
->end()
418444
->end();
419445

src/DependencyInjection/HttplugExtension.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,11 @@ private function configurePluginByName($name, Definition $definition, array $con
264264

265265
break;
266266

267+
case 'request_seekable_body':
268+
case 'response_seekable_body':
269+
$definition->replaceArgument(0, $config);
270+
break;
271+
267272
default:
268273
throw new \InvalidArgumentException(sprintf('Internal exception: Plugin %s is not handled', $name));
269274
}

tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ public function testClientPlugins()
103103
'headers' => ['X-FOO'],
104104
],
105105
],
106+
[
107+
'request_seekable_body' => [
108+
'use_file_buffer' => true,
109+
],
110+
],
111+
// 'response_seekable_body',
106112
[
107113
'query_defaults' => [
108114
'parameters' => ['locale' => 'en'],

0 commit comments

Comments
 (0)