Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support for API calls #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion class/transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
if (false === defined('CS_REST_CALL_TIMEOUT')) {
define('CS_REST_CALL_TIMEOUT', 20);
}
if (false === defined('CS_REST_PROXY')) {
define('CS_REST_PROXY', '');
}
if (false === defined('CS_REST_PROXY_PORT')) {
define('CS_REST_PROXY_PORT', '');
}
if (false === defined('CS_REST_NO_PROXY')) {
define('CS_REST_NO_PROXY', '');
}

if(!function_exists("CS_REST_TRANSPORT_get_available")) {
function CS_REST_TRANSPORT_get_available($requires_ssl, $log) {
Expand Down Expand Up @@ -164,6 +173,11 @@ function make_call($call_options) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}

// Add proxy settings.
curl_setopt($ch, CURLOPT_PROXY, CS_REST_PROXY);
curl_setopt($ch, CURLOPT_PROXYPORT, CS_REST_PROXY_PORT);
curl_setopt($ch, CURLOPT_NOPROXY, CS_REST_NO_PROXY);

$response = curl_exec($ch);

if(!$response && $response !== '') {
Expand Down Expand Up @@ -349,4 +363,4 @@ function _build_request($call_options, $host, $path, $accept_gzip) {
return $request."\n\n";
}
}
}
}