Skip to content

Commit c90ffe2

Browse files
author
Younès El Biache
committed
guzzle default config; project composer conditionnal load
1 parent 6e6799b commit c90ffe2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/RequestResolvers/Guzzle.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ class Guzzle implements RequestResolverInterface
2121
*/
2222
protected $response;
2323

24+
protected $defaultConfig = [
25+
'verify' => false,
26+
'timeout' => 10,
27+
'connect_timeout' => 20,
28+
'headers' => [
29+
'User-Agent' => 'Embed PHP Library',
30+
],
31+
'allow_redirects' => [
32+
'max' => 20,
33+
'referer' => true,
34+
],
35+
];
36+
2437
/**
2538
* Constructor. Sets the url
2639
*
@@ -29,7 +42,10 @@ class Guzzle implements RequestResolverInterface
2942
*/
3043
public function __construct($url, array $config)
3144
{
32-
$this->client = isset($config['client']) ? $config['client'] : new Client();
45+
$this->client = isset($config['client']) ? $config['client'] : new Client([
46+
'defaults' => $this->defaultConfig,
47+
]);
48+
3349
$this->request = $this->client->createRequest('GET', $url);
3450
}
3551

tests/bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22
error_reporting(E_ALL);
33

4+
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
5+
require_once(__DIR__ . '/../vendor/autoload.php');
6+
}
7+
48
include_once dirname(__DIR__).'/src/autoloader.php';
59
include_once __DIR__.'/TestCaseBase.php';
610

0 commit comments

Comments
 (0)