Skip to content

Commit 4722773

Browse files
committed
WIP configure seekable body plugin
1 parent ddbd6dc commit 4722773

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
@@ -488,6 +488,32 @@ private function createClientPluginNode()
488488
->info('Where the responses will be stored and replay from when using the filesystem recorder. Should be accessible to your VCS.')
489489
->end()
490490
->end()
491+
->arrayNode('request_seekable_body')
492+
->canBeEnabled()
493+
->info('Ensure that the request body is seekable so that several plugins can look into it.')
494+
->children()
495+
->booleanNode('use_file_buffer')
496+
->info('Whether to use a file buffer if the stream is too big for a memory buffer')
497+
->defaultTrue()
498+
->end()
499+
->scalarNode('memory_buffer_size')
500+
->info('Maximum memory size in bytes before using a file buffer if use_file_buffer is true. Defaults to 2 MB')
501+
->end()
502+
->end()
503+
->end()
504+
->arrayNode('response_seekable_body')
505+
->canBeEnabled()
506+
->info('Ensure that the response body is seekable so that several plugins can look into it.')
507+
->children()
508+
->booleanNode('use_file_buffer')
509+
->info('Whether to use a file buffer if the stream is too big for a memory buffer')
510+
->defaultTrue()
511+
->end()
512+
->scalarNode('memory_buffer_size')
513+
->info('Maximum memory size in bytes before using a file buffer if use_file_buffer is true. Defaults to 2 MB')
514+
->end()
515+
->end()
516+
->end()
491517
->end()
492518
->end();
493519

src/DependencyInjection/HttplugExtension.php

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

342342
break;
343343

344+
case 'request_seekable_body':
345+
case 'response_seekable_body':
346+
$definition->replaceArgument(0, $config);
347+
break;
348+
344349
default:
345350
throw new \InvalidArgumentException(sprintf('Internal exception: Plugin %s is not handled', $name));
346351
}

tests/Unit/DependencyInjection/HttplugExtensionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ public function testClientPlugins(): void
120120
'headers' => ['X-FOO'],
121121
],
122122
],
123+
[
124+
'request_seekable_body' => [
125+
'use_file_buffer' => true,
126+
],
127+
],
128+
// 'response_seekable_body',
123129
[
124130
'query_defaults' => [
125131
'parameters' => ['locale' => 'en'],

0 commit comments

Comments
 (0)