Skip to content

Commit

Permalink
Add proxy support (#2)
Browse files Browse the repository at this point in the history
Add proxy support
  • Loading branch information
Jamie Learmonth authored and Bilge committed Oct 5, 2016
1 parent 4449b11 commit db670fa
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Porter/Net/Http/HttpOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ public function setContent($content)
return $this->set('content', "$content");
}

/**
* @return string
*/
public function getProxy()
{
return $this->get('proxy');
}

/**
* @param string $proxy
*
* @return $this
*/
public function setProxy($proxy)
{
return $this->set('proxy', "$proxy");
}

/**
* Extracts a list of HTTP context options only.
*
Expand Down
40 changes: 40 additions & 0 deletions src/Porter/Net/Soap/SoapOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,46 @@ public function setKeepAlive($keepAlive)
return $this->set('keep_alive', (bool)$keepAlive);
}

public function setProxyHost($host)
{
return $this->set('proxy_host', "$host");
}

public function getProxyHost()
{
return $this->get('proxy_host');
}

public function setProxyPort($port)
{
return $this->set('proxy_port', $port|0);
}

public function getProxyPort()
{
return $this->get('proxy_port');
}

public function setProxyLogin($login)
{
return $this->set('proxy_login', "$login");
}

public function getProxyLogin()
{
return $this->get('proxy_login');
}

public function setProxyPassword($password)
{
return $this->set('proxy_password', "$password");
}

public function getProxyPassword()
{
return $this->get('proxy_password');
}

/**
* Extracts a list of SOAP Client options only.
*
Expand Down
5 changes: 5 additions & 0 deletions test/Unit/Porter/Net/Http/HttpOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public function testReplaceHeaders()
self::assertCount(2, $options->getHeaders());
}

public function testProxy()
{
self::assertSame($host = 'https://foo.com:80', (new HttpOptions)->setProxy($host)->getProxy());
}

public function testExtractHttpContextOptions()
{
self::assertSame(['header' => []], (new HttpOptions)->extractHttpContextOptions());
Expand Down
14 changes: 14 additions & 0 deletions test/Unit/Porter/Net/Soap/SoapOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,20 @@ public function testKeepAlive()
self::assertFalse($options->setKeepAlive(false)->getKeepAlive());
}

public function testProxy()
{
$options = (new SoapOptions)
->setProxyHost($host = 'foo.com')
->setProxyPort($port = 8080)
->setProxyLogin($login = 'foo')
->setProxyPassword($password = 'bar');

self::assertSame($host, $options->getProxyHost());
self::assertSame($port, $options->getProxyPort());
self::assertSame($login, $options->getProxyLogin());
self::assertSame($password, $options->getProxyPassword());
}

public function testExtractSoapClientOptions()
{
$options = new SoapOptions;
Expand Down

0 comments on commit db670fa

Please sign in to comment.