diff --git a/src/Configuration.php b/src/Configuration.php index 9e5dffd..ca05cd6 100644 --- a/src/Configuration.php +++ b/src/Configuration.php @@ -18,6 +18,8 @@ class Configuration private array $target; + private string $httpTimeout = ''; + private bool $httpDebug = false; public function __construct(string $name, string $description = '') @@ -48,6 +50,9 @@ public function toArray(): array if (trim($this->duration) !== '') { $array['duration'] = $this->duration; } + if (trim($this->httpTimeout) !== '') { + $array['http_timeout'] = $this->httpTimeout; + } return $array; } @@ -92,6 +97,16 @@ public function setTarget(string $idleTimeout = '30s'): self return $this; } + public function setHttpTimeout(string $httpTimeout): self + { + if (! preg_match('/^\d+[smh]$/', $httpTimeout)) { + throw new VoltTestException('Invalid HTTP timeout format. Use [s|m|h]'); + } + $this->httpTimeout = $httpTimeout; + + return $this; + } + public function setHttpDebug(bool $httpDebug): self { $this->httpDebug = $httpDebug; diff --git a/src/VoltTest.php b/src/VoltTest.php index 51e0711..5c71b65 100644 --- a/src/VoltTest.php +++ b/src/VoltTest.php @@ -68,6 +68,22 @@ public function setRampUp(string $rampUp): self return $this; } + /** + * Set the HTTP request timeout (per-request) + * @param string $timeout e.g. "60s", "2m" — default is 30s + * @return $this + * @throws VoltTestException + */ + public function setHttpTimeout(string $timeout): self + { + if (! preg_match('/^\d+[smh]$/', $timeout)) { + throw new VoltTestException('Invalid HTTP timeout format. Use [s|m|h]'); + } + $this->config->setHttpTimeout($timeout); + + return $this; + } + public function setHttpDebug(bool $httpDebug): self { $this->config->setHttpDebug($httpDebug);