Skip to content

Commit 2d8c3c7

Browse files
committed
Adds a timeout to the webhook options
1 parent c6b8da2 commit 2d8c3c7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Log/Webhook.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ class Webhook implements Listener, Logger
4343
*/
4444
private $method;
4545

46+
/**
47+
* Request timeout (seconds)
48+
*
49+
* @var int
50+
*/
51+
private $timeout;
52+
4653
/**
4754
* Basic auth username
4855
*
@@ -127,6 +134,7 @@ public function setup(array $options)
127134
$this->password = Arr::getValue($options, 'password', '');
128135
$this->template = Arr::getValue($options, 'template', '');
129136
$this->contentType = Arr::getValue($options, 'contentType', 'multipart/form-data');
137+
$this->timeout = Arr::getValue($options, 'timeout', '');
130138
}
131139

132140
/**
@@ -219,6 +227,10 @@ protected function fireRequest(string $uri, string $body = '')
219227
$options['http']['content'] = $body;
220228
}
221229

230+
if (!empty($this->timeout)) {
231+
$options['http']['timeout'] = $this->timeout;
232+
}
233+
222234
if (!empty($this->username)) {
223235
$headers[] = 'Authorization: Basic ' . base64_encode($this->username . ':' . $this->password);
224236
}

0 commit comments

Comments
 (0)