On Wed, Feb 24, 2010 at 11:36 AM, Matthew Weier O'Phinney
<[email protected]> wrote:
> -- 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.

Hmm. OK. I thought HTTP_HOST contained the value of the Host: header
in the request, which as far as I've seen always matches the browser's
address bar (including the port, when specified).

>> 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.

Interestingly, I have not noticed any issues with the redirection
itself, so I don't think I need to extend the action helper.  I'm not
at all sure why it seems to work inside the action helper (unless in
that case _redirect is already receiving an absolute URL, though I
doubt it), but the exact same snippet of code copied and pasted to the
controller builds the URL incorrectly.

Andrew

Reply via email to