Skip to content

Commit 3070ff7

Browse files
committed
WIP configure seekable body plugin
1 parent 8b7cb00 commit 3070ff7

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

DependencyInjection/Configuration.php

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

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)