Skip to content

Commit

Permalink
Merge pull request #223 from ocean90/proxy-instance
Browse files Browse the repository at this point in the history
Support a Requests_Proxy_HTTP() instance for the proxy setting.
  • Loading branch information
rmccue authored Jul 12, 2016
2 parents 2781cdd + 1c5455d commit 539cdfd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions library/Requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ public static function patch($url, $headers, $data = array(), $options = array()
* for Basic authentication
* (Requests_Auth|array|boolean, default: false)
* - `proxy`: Proxy details to use for proxy by-passing and authentication
* (Requests_Proxy|array|boolean, default: false)
* (Requests_Proxy|array|string|boolean, default: false)
* - `max_bytes`: Limit for the response body size.
* (integer|boolean, default: false)
* - `idn`: Enable IDN parsing
Expand Down Expand Up @@ -575,7 +575,7 @@ protected static function set_defaults(&$url, &$headers, &$data, &$type, &$optio
$options['auth']->register($options['hooks']);
}

if (!empty($options['proxy'])) {
if (is_string($options['proxy']) || is_array($options['proxy'])) {
$options['proxy'] = new Requests_Proxy_HTTP($options['proxy']);
}
if ($options['proxy'] !== false) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Proxy/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function testConnectWithInstance($transport) {
$this->checkProxyAvailable();

$options = array(
'proxy' => REQUESTS_HTTP_PROXY,
'proxy' => new Requests_Proxy_HTTP(REQUESTS_HTTP_PROXY),
'transport' => $transport,
);
$response = Requests::get(httpbin('/get'), array(), $options);
Expand Down Expand Up @@ -128,4 +128,4 @@ public function testConnectWithInvalidAuth($transport) {
$response = Requests::get(httpbin('/get'), array(), $options);
$this->assertEquals(407, $response->status_code);
}
}
}

0 comments on commit 539cdfd

Please sign in to comment.