Changeset 1015

Show
Ignore:
Timestamp:
11/09/07 14:41:37 (1 year ago)
Author:
richi
Message:

added support for URL params without value (e.g. "http://example.org?wsdl" or "http://example.org?key1&foo=bar&key2")

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/util/net/http/stubHTTPURL.php

    r777 r1015  
    188188                } 
    189189                 
    190                 $query .= $key . '=' . urlencode($value); 
     190                if($value !== '') { 
     191                    $query .= $key . '=' . urlencode($value); 
     192                } else { 
     193                    $query .= $key; 
     194                } 
    191195            } else { 
    192196                foreach ($value as $assoc_key => $single) { 
  • trunk/src/test/php/net/stubbles/util/net/http/stubHTTPURLTestCase.php

    r719 r1015  
    170170 
    171171    /** 
     172     * assure that paramter without value is valid 
     173     * e.g.: http://example.org?wsdl  
     174     *       http://example.org?key1&foo=bar&key2  
     175     */ 
     176    public function testKeyWithoutParam() 
     177    { 
     178        $http = stubHTTPURL::fromString('http://example.org/'); 
     179        $this->assertFalse($http->hasQuery()); 
     180        $http->addParam('key1', ''); 
     181        $this->assertTrue($http->hasQuery()); 
     182        $this->assertEqual($http->get(),'http://example.org/?key1'); 
     183        $http->addParam('foo', 'bar'); 
     184        $http->addParam('key2', ''); 
     185        $this->assertEqual($http->get(),'http://example.org/?key1&foo=bar&key2'); 
     186    } 
     187     
     188    /** 
    172189     * assure that wrong parameters throw an exception 
    173190     */