Issues

ZF-1934: http client fails on redirects with malformed urls

Issue Type: Bug Created: 2007-09-12T08:39:00.000+0000 Last Updated: 2008-03-21T16:25:28.000+0000 Status: Resolved Fix version(s): - 1.5.0 (17/Mar/08)

Reporter: Karol Grecki (antych) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

Related issues: Attachments:

Description

I have code failing with exception like this: Stack trace:

0 /home/kgrecki/ZendFramework-1.0.1/library/Zend/Uri/Http.php(528): Zend_Uri_Http->_parseQuery('source_id=a&ur...')

1 /home/kgrecki/ZendFramework-1.0.1/library/Zend/Http/Client.php(800): Zend_Uri_Http->setQuery('source_id=a&ur...')

2 /home/tests/Case/Abstract.php(84): Zend_Http_Client->request()

I use http client for functional testing, grabbing requests from apache log and comparing responses. The problem is when a redirect happens and the destination url has malformed query string. It fails on validating the query string, probably because the url is not encoded. I think the client should behave the same as the browsers ale letting this url through. Currently I cannot test the response even when using 'maxredirects' => 0 because the exception is thrown before the request.

Comments

Posted by Thomas Weidner (thomas) on 2007-09-12T13:32:55.000+0000

Assigned to Shahar

Posted by Shahar Evron (shahar) on 2007-10-16T20:30:55.000+0000

Can you paste here the URL that the client tries to redirect to? You can do that using such code:

<pre class="highlight">
// Set the first URI and all...

$client->setConfig(array('maxredirects' => 0));
$respons = $client->request(); 

echo $response->getHeadersAsString();

and paste the output here.

Posted by Karol Grecki (antych) on 2007-10-17T03:39:57.000+0000

This snippet will not work as it throws an exception on first ->request(), but it can be tested by commenting out this line //$this->uri->setQuery($query); in Http/Client.php The sample url would look like http://localhost/redirect.php/… bar

It triggers 'Zend_Uri_Exception' with message 'Invalid URI supplied' if I try to connect to it directly using the client. I can understand why it's invalid, the thing is that it's being accepted by browsers. So I think the client should behave the same or at least have a configuration option that would allow this. Also the exception may be thrown prematurely as this url is never requested in my code if I use maxredirects' => 0 so maybe the url validation should be done later before the actual request to redirected url. Hope that helps.

Posted by Shahar Evron (shahar) on 2007-10-17T06:24:01.000+0000

Zend_Uri_Http was fixed to encode query parameters which are not valid.

Should be resolved by revision 6654. If you can verify that, it would help greatly.

Posted by Karol Grecki (antych) on 2007-10-17T09:59:29.000+0000

Confirmed resolved by rev 6654 Thanks Shahar

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts