Skip to content

Commit

Permalink
Merge pull request #185 from jorissteyn/feature/web-adapter-host-header
Browse files Browse the repository at this point in the history
Support adding host header to web adapter
  • Loading branch information
gordalina committed Jun 10, 2021
2 parents 96c0c51 + eaa3b13 commit d246889
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ protected function getDefaultInputDefinition()
$definition->addOption(new InputOption('--web-url', null, InputOption::VALUE_OPTIONAL, 'If specified, used as a information for web adapter'));
$definition->addOption(new InputOption('--web-allow-insecure', null, InputOption::VALUE_OPTIONAL, 'If specified, verify_peer and verify_host are disabled (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--web-basic-auth', null, InputOption::VALUE_OPTIONAL, 'If specified, used for basic authorization (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--web-host', null, InputOption::VALUE_OPTIONAL, 'If specified, adds a Host header to web adapter request (only for SymfonyHttpClient)'));
$definition->addOption(new InputOption('--tmp-dir', '-t', InputOption::VALUE_REQUIRED, 'Temporary directory to write files to'));
$definition->addOption(new InputOption('--config', '-c', InputOption::VALUE_REQUIRED, 'If specified use this yaml configuration file'));
return $definition;
Expand Down Expand Up @@ -207,6 +208,10 @@ private function parseConfiguration(InputInterface $input)
if ($input->hasParameterOption('--web-basic-auth')) {
$this->config['webBasicAuth'] = $input->getParameterOption('--web-basic-auth');
}

if ($input->hasParameterOption('--web-host')) {
$this->config['webHost'] = $input->getParameterOption('--web-host');
}
}
}

Expand All @@ -218,7 +223,9 @@ private function parseConfiguration(InputInterface $input)

case 'SymfonyHttpClient':

$symfonyHttpClientConfig = [];
$symfonyHttpClientConfig = [
'headers' => [],
];

if ($this->config['webAllowInsecure']) {
$symfonyHttpClientConfig['verify_peer'] = false;
Expand All @@ -229,6 +236,10 @@ private function parseConfiguration(InputInterface $input)
$symfonyHttpClientConfig['auth_basic'] = $this->config['webBasicAuth'];
}

if (isset($this->config['webHost'])) {
$symfonyHttpClientConfig['headers']['Host'] = $this->config['webHost'];
}

$this->config['http'] = new SymfonyHttpClient($this->config['webUrl'], $symfonyHttpClientConfig);
break;

Expand Down

0 comments on commit d246889

Please sign in to comment.