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

Support a Requests_Proxy_HTTP() instance for the proxy setting. #223

Merged
merged 3 commits into from
Jul 12, 2016
Merged
Show file tree
Hide file tree
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
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);
}
}
}