-- Andrew Ballard <[email protected]> wrote
(on Wednesday, 24 February 2010, 11:20 AM -0500):
> I think I uncovered a potential bug in
> Zend_Controller_Action_Helper_Redirector, but I want to be sure. The
> method Zend_Controller_Action_Helper_Redirector::_redirect() is
> currently implemented this way:

<snip - implementation>

> However, are the lines that assign a value to $port and the
> corresponding if...then test that conditionally appends $port to $uri
> necessary? In my experience, the port number for non-default ports is
> already part of $_SERVER['HTTP_HOST'], so this seems redundant. Are
> there instances where this is not the case?

Actually, yes -- in many cases, HTTP_HOST contains only the host name,
while HTTP_PORT contains the actual port over which the request came.

> I copied the logic from this method to a function I use to build
> absolute URLs that get passed via JSON to a web browser. It worked
> fine until we moved one of our applications to a new system behind a
> load balancer. The public address is a typical host name such as
> www.hostname.com that uses the default ports 80/443, but the request
> is forwarded from the load balancer to a web server via an address
> like 192.168.1.125:50001. When we moved the application to this
> system, I noticed that the URLs being built in my function (using the
> same logic as above) were for the hostname www.hostname.com:50001,
> which is not a valid address/port assignment.

Interesting -- can't say that I've witnessed this, but I can see why it
might happen.

My suggestion is to extend the Redirector action helper to accomodate
your needs, as they sound quite specific to your architecture. You'll
likely want to configure the redirector in your bootstrap to specify the
host name and port, instead of have them auto-discovered.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Reply via email to