Skip to content

Commit

Permalink
Merge pull request #45 from isrob/master
Browse files Browse the repository at this point in the history
Added HTTP proxy support
  • Loading branch information
dbtlr committed Apr 30, 2015
2 parents 5d6db50 + 1bf1ab0 commit d372539
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ Configuration Options
- **hostname** - The hostname that was requested.
- **secure** - Optional - Boolean that allows you to define if you want to hit the secure Airbrake endpoint.
- **errorReportingLevel** - Optional - functions the same way as the error_reporting php.ini setting (this is applied on top of show warnings parameter on the EventHandler::start method)
- **proxyHost** - An optional HTTP proxy host through which all connections will be sent.
- **proxyPort** - The HTTP proxy port (required only if proxyHost is supplied). Defaults to 80.
- **proxyUser** - The HTTP proxy username (optional even if proxyHost is supplied).
- **proxyPass** - The HTTP proxy password (required only if proxyUser is supplied).

Filters
=======
Expand Down
4 changes: 4 additions & 0 deletions src/Airbrake/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class Configuration extends Record
'apiEndPoint' => null,
'errorReportingLevel' => null,
'extraParameters' => null,
'proxyHost' => null,
'proxyPort' => 80,
'proxyUser' => null,
'proxyPass' => null
);

/** @var array */
Expand Down
11 changes: 11 additions & 0 deletions src/Airbrake/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,17 @@ public function send(Notice $notice)
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);

// HTTP proxy support
$proxyHost = $this->configuration->get('proxyHost');
$proxyUser = $this->configuration->get('proxyUser');

if (null !== $proxyHost) {
curl_setopt($curl, CURLOPT_PROXY, $proxyHost.':'.$this->configuration->get('proxyPort'));
if (null !== $proxyUser) {
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser.':'.$this->configuration->get('proxyPass'));
}
}

$return = curl_exec($curl);
curl_close($curl);

Expand Down

0 comments on commit d372539

Please sign in to comment.