Skip to content

Commit

Permalink
Merge pull request #80 from ramiel/proxy_support
Browse files Browse the repository at this point in the history
Added proxy support
  • Loading branch information
nategood committed Jun 27, 2013
2 parents 6d62777 + fe3c11b commit ed55e6b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Httpful/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,31 @@ public function withStrictSSL()
{
return $this->strictSSL(true);
}

/**
* Use proxy configuration
* @return Request this
* @param string $proxy_host Hostname or address of the proxy
* @param number $proxy_port Port of the proxy. Default 80
* @param string $auth_type Authentication type or null. Accepted values are CURLAUTH_BASIC, CURLAUTH_NTLM. Default null, no authentication
* @param string $auth_username Authentication username. Default null
* @param string $auth_password Authentication password. Default null
*/
public function useProxy($proxy_host, $proxy_port = 80, $auth_type = null, $auth_username = null, $auth_password = null){
$this->addOnCurlOption(CURLOPT_PROXY, "{$proxy_host}:{$proxy_port}");
if(in_array($auth_type, array(CURLAUTH_BASIC,CURLAUTH_NTLM)) ){
$this->addOnCurlOption(CURLOPT_PROXYAUTH, $auth_type)
->addOnCurlOption(CURLOPT_PROXYUSERPWD, "{$auth_username}:{$auth_password}");
}
return $this;
}

/**
* @return is this request setup for using proxy?
*/
public function hasProxy(){
return is_string($this->additional_curl_opts[CURLOPT_PROXY]);
}

/**
* Determine how/if we use the built in serialization by
Expand Down

0 comments on commit ed55e6b

Please sign in to comment.