[Catalyst] Resurrected: HTTP redirect - delayed Firefox
Svilen Ivanov
svilen.ivanov at gmail.com
Fri Feb 23 22:04:08 GMT 2007
Hi,
Today I received this email from Ryan explaining the problem with
Firefox and strange delay in keep-alive. In nutshell the problem is
lack of content-length in headers could be added easily (see below).
Regards,
Svi
---------- Forwarded message ----------
From: Ryan VanderBijl
Date: 23.02.2007 13:55
Subject: Catalyst keepalive/firefox problem (possible fix)
I'm developing/testing my application using :
./scripts/myapp_server.pl -r -f
I was having problems when browsing the site using IE. Some (but not
all) of my redirects were having problems (using both 302 and 303
redirects).
Eventually I stumbled upon a suggestion to use the -k keep-alive
option. This fixed the IE redirect problem, but Firefox seems to always
wait 5 seconds after each redirect. (i expected this, as the suggestion
for -k came from the list archive with the title of "HTTP redirect -
delayed Firefox") This corresponds to the Catalyst::Engine::HTTP
can_read(5) call, near the end of the _handle_request function.
Anyways, although I still don't understand why IE needs the -k option to
redirect properly, I think I've solved the Firefox Delay problem.
The HTTP/1.1 RFC says in section 8.1.2.1:
In order to remain persistent, all messages on the connection MUST
have a self-defined message length (i.e., one not defined by closure
of the connection), as described in section 4.4.
But the Engine::HTTP doesn't provide the Content-Length. This can be fixed
by adding a few lines in finalize_headers (Engine/HTTP.pm, at line 53):
if ($self->_keep_alive) {
$c->response->headers->content_length( length($c->response->body) );
}
Both IE and Firefox seem to play well this change.
Now if only we could figure out why IE doesn't work without the -k...
Otherwise I suggest that we make the -k the default. Having all browsers
play nicely be default is a good thing (IMO). (And might save someone
else a day of trying to track down an elusive bug).
I'm not on the catalyst mailing list, so it bounched this message back to me.
I don't feel like joining just to send this email.
Thanks for your time,
-Ryan
--
Ryan VanderBijl | http://vbijl.net/~ryan/
More information about the Catalyst
mailing list