Skip to content

Commit be9bed5

Browse files
Jamie LearmonthBilge
authored andcommitted
Added proxy support to HttpOptions and SoapOptions.
1 parent 4449b11 commit be9bed5

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

src/Porter/Net/Http/HttpOptions.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,24 @@ public function setContent($content)
133133
return $this->set('content', "$content");
134134
}
135135

136+
/**
137+
* @return string
138+
*/
139+
public function getProxy()
140+
{
141+
return $this->get('proxy');
142+
}
143+
144+
/**
145+
* @param string $proxy
146+
*
147+
* @return $this
148+
*/
149+
public function setProxy($proxy)
150+
{
151+
return $this->set('proxy', "$proxy");
152+
}
153+
136154
/**
137155
* Extracts a list of HTTP context options only.
138156
*

src/Porter/Net/Soap/SoapOptions.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,46 @@ public function setKeepAlive($keepAlive)
5555
return $this->set('keep_alive', (bool)$keepAlive);
5656
}
5757

58+
public function setProxyHost($host)
59+
{
60+
return $this->set('proxy_host', "$host");
61+
}
62+
63+
public function getProxyHost()
64+
{
65+
return $this->get('proxy_host');
66+
}
67+
68+
public function setProxyPort($port)
69+
{
70+
return $this->set('proxy_port', $port|0);
71+
}
72+
73+
public function getProxyPort()
74+
{
75+
return $this->get('proxy_port');
76+
}
77+
78+
public function setProxyLogin($login)
79+
{
80+
return $this->set('proxy_login', "$login");
81+
}
82+
83+
public function getProxyLogin()
84+
{
85+
return $this->get('proxy_login');
86+
}
87+
88+
public function setProxyPassword($password)
89+
{
90+
return $this->set('proxy_password', "$password");
91+
}
92+
93+
public function getProxyPassword()
94+
{
95+
return $this->get('proxy_password');
96+
}
97+
5898
/**
5999
* Extracts a list of SOAP Client options only.
60100
*

test/Unit/Porter/Net/Http/HttpOptionsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ public function testReplaceHeaders()
6060
self::assertCount(2, $options->getHeaders());
6161
}
6262

63+
public function testProxy()
64+
{
65+
self::assertSame($host = 'https://foo.com:80', (new HttpOptions)->setProxy($host)->getProxy());
66+
}
67+
6368
public function testExtractHttpContextOptions()
6469
{
6570
self::assertSame(['header' => []], (new HttpOptions)->extractHttpContextOptions());

test/Unit/Porter/Net/Soap/SoapOptionsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ public function testKeepAlive()
4444
self::assertFalse($options->setKeepAlive(false)->getKeepAlive());
4545
}
4646

47+
public function testProxy()
48+
{
49+
$options = (new SoapOptions)
50+
->setProxyHost($host = 'foo.com')
51+
->setProxyPort($port = 8080)
52+
->setProxyLogin($login = 'foo')
53+
->setProxyPassword($password = 'bar');
54+
55+
self::assertSame($host, $options->getProxyHost());
56+
self::assertSame($port, $options->getProxyPort());
57+
self::assertSame($login, $options->getProxyLogin());
58+
self::assertSame($password, $options->getProxyPassword());
59+
}
60+
4761
public function testExtractSoapClientOptions()
4862
{
4963
$options = new SoapOptions;

0 commit comments

Comments
 (0)