Skip to content

Commit

Permalink
remove hardcoded connect_timeout
Browse files Browse the repository at this point in the history
 and add default config for it on HttpClient in TransportManager
  • Loading branch information
RTLer committed May 19, 2016
1 parent d49e82b commit a7091fd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/Illuminate/Mail/Transport/MailgunTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
'message' => new PostFile('message', $message->toString()),
];
}
$options['connect_timeout'] = 60;

return $this->client->post($this->url, $options);
}
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Mail/Transport/MandrillTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
} else {
$options = ['body' => $data];
}
$options['connect_timeout'] = 60;

return $this->client->post('https://mandrillapp.com/api/1.0/messages/send-raw.json', $options);
}
Expand Down
1 change: 0 additions & 1 deletion src/Illuminate/Mail/Transport/SparkPostTransport.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
$message->setBcc([]);

$options = [
'connect_timeout' => 60,
'headers' => [
'Authorization' => $this->key,
],
Expand Down
21 changes: 18 additions & 3 deletions src/Illuminate/Mail/TransportManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected function createMailgunDriver()
$config = $this->app['config']->get('services.mailgun', []);

return new MailgunTransport(
new HttpClient(Arr::get($config, 'guzzle', [])),
$this->getHttpClient($config),
$config['secret'], $config['domain']
);
}
Expand All @@ -116,7 +116,7 @@ protected function createMandrillDriver()
$config = $this->app['config']->get('services.mandrill', []);

return new MandrillTransport(
new HttpClient(Arr::get($config, 'guzzle', [])), $config['secret']
$this->getHttpClient($config), $config['secret']
);
}

Expand All @@ -130,7 +130,7 @@ protected function createSparkPostDriver()
$config = $this->app['config']->get('services.sparkpost', []);

return new SparkPostTransport(
new HttpClient(Arr::get($config, 'guzzle', [])), $config['secret']
$this->getHttpClient($config), $config['secret']
);
}

Expand Down Expand Up @@ -164,4 +164,19 @@ public function setDefaultDriver($name)
{
$this->app['config']['mail.driver'] = $name;
}

/**
* get configured http client
* @param $config
* @return HttpClient
*/
protected function getHttpClient($config)
{
$guzzleConfig = Arr::get($config, 'guzzle', []);

// add default config for timeout
$guzzleConfig = Arr::add($guzzleConfig, 'connect_timeout', 60);

return new HttpClient($guzzleConfig);
}
}

0 comments on commit a7091fd

Please sign in to comment.