Changeset 1491
- Timestamp:
- 04/04/08 11:37:14 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/peer/http/stubHTTPConnection.php
r1486 r1491 45 45 * constructor 46 46 * 47 * @param stubHTTPURL $http url to create connection to 47 * @param stubHTTPURL $http url to create connection to 48 * @param stubHeaderList $headers optional list of headers to be used 48 49 */ 49 public function __construct(stubHTTPURL $http )50 public function __construct(stubHTTPURL $http, stubHeaderList $headers = null) 50 51 { 51 52 $this->url = $http; 52 $this->headers = new stubHeaderList(); 53 if (null === $headers) { 54 $this->headers = new stubHeaderList(); 55 } else { 56 $this->headers = $headers; 57 } 58 } 59 60 /** 61 * returns list of headers 62 * 63 * @return stubHeaderList 64 */ 65 public function getHeaderList() 66 { 67 return $this->headers; 53 68 } 54 69 trunk/src/main/php/net/stubbles/peer/http/stubHTTPURL.php
r1486 r1491 169 169 * </code> 170 170 * 171 * @param stubHeaderList $headers optional list of headers to be used 171 172 * @return stubHTTPConnection 172 173 */ 173 public function connect( )174 public function connect(stubHeaderList $headers = null) 174 175 { 175 176 stubClassLoader::load('net::stubbles::peer::http::stubHTTPConnection'); 176 return new stubHTTPConnection($this );177 return new stubHTTPConnection($this, $headers); 177 178 } 178 179 trunk/src/test/php/net/stubbles/peer/http/stubHTTPURLTestCase.php
r1486 r1491 105 105 106 106 /** 107 * assure that values are returned the expected way 108 * 109 * @test 110 */ 111 public function valueHTTPSIP() 112 { 113 $http = stubHTTPURL::fromString('https://127.0.0.1:125/'); 114 $this->assertTrue($http->isValid()); 115 $this->assertFalse($http->hasDefaultPort()); 116 $this->assertEquals('https://127.0.0.1/', $http->get()); 117 $this->assertEquals('https://127.0.0.1:125/', $http->get(true)); 118 $this->assertEquals('127.0.0.1', $http->getHost()); 119 $this->assertEquals(125, $http->getPort()); 120 $this->assertEquals($http->getPath(), '/'); 121 $this->assertFalse($http->hasQuery()); 122 $this->assertTrue($http->checkDNS()); 123 } 124 125 /** 107 126 * assure that wrong values trigger an exception 108 127 * … … 242 261 $this->assertType('stubHTTPConnection', $httpconnection); 243 262 } 263 264 /** 265 * assure getting a connection works as expected 266 * 267 * @test 268 */ 269 public function connectionWithHeaderList() 270 { 271 $http = stubHTTPURL::fromString('http://example.com/'); 272 $headers = new stubHeaderList(); 273 $httpconnection = $http->connect($headers); 274 $this->assertType('stubHTTPConnection', $httpconnection); 275 $this->assertSame($headers, $httpconnection->getHeaderList()); 276 } 244 277 } 245 278 ?>
