ZF-179: when redirect to another host, header don't set a new host name.

Issue Type: Bug Created: 2006-06-30T22:23:11.000+0000 Last Updated: 2007-07-05T14:44:31.000+0000 Status: Closed Fix version(s): - 0.1.5 (11/Jul/06)

Reporter: Naoto Ishikawa (ishinao) Assignee: Shahar Evron (shahar) Tags: - Zend_Http_Client

Related issues: Attachments:


With Zend_Http_Client incubator version, When a redirect response to another host is returned, the _prepare_headers method doesn't set the new host name, so the redirect action doesn't work rightly.

    // Set the host header
    if (! isset($this->headers['host'])) {
        $host = $this->uri->getHost() . ($this->uri->getPort() == 80 ? '' : ':' . $this->uri->getPort());
        $this->setHeader('host', $host);

will be fixed to

    // Set the host header
    $host = $this->uri->getHost() . ($this->uri->getPort() == 80 ? '' : ':' . $this->uri->getPort());
    $this->setHeader('host', $host);

Please check it.


Posted by Shahar Evron (shahar) on 2006-07-01T10:05:15.000+0000

Please test again with revision 771 - I think the bug is fixed but I have no way to test it right now.

I didn't use the patch you proposed because I want to give people the option to override the "Host" header if they want to by setting it before the request. Instead, I changed the Zend_Http_Client::request() code to unset the "Host" header when redirecting to a valid URI.

Let me know if the problem is solved or not.

Posted by Jayson Minard (jayson) on 2006-07-09T00:44:43.000+0000

Has this been confirmed fixed? If not, set the fix version to 0.2.0 and try to confirm by then.

Posted by Naoto Ishikawa (ishinao) on 2006-07-09T23:34:44.000+0000

Sorry, too late. I tested to access "" with trunk version(revision 866). And success redirecting to another host url: "". Thanks.

// test code require_once 'Zend.php'; require_once 'Zend/Http/Client.php';

$url = ''; $client = new Zend_Http_Client($url); $response = $client->get(); echo $client->getUri(); //

Posted by Shahar Evron (shahar) on 2006-07-10T02:49:58.000+0000

Then I guess this confirms that the issue is fixed.

Thank you.

Posted by Jayson Minard (jayson) on 2006-07-11T11:54:38.000+0000

0.1.5 released

Have you found an issue?

See the Overview section for more details.


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

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