mod_perl logo perl icon
previous page: Cute Tricks With Perl and Apachepage up: Tutorialsnext page: Web Content Compression FAQ

Workarounds for some known bugs in browsers.






Embedding Perl in HTML with Mason

Embedding Perl in HTML with Mason

By Dave Rolsky, Ken Williams
mod_perl2 User's Guide

mod_perl2 User's Guide

By Stas Bekman, Jim Brandt
Practical mod_perl

Practical mod_perl

By Stas Bekman, Eric Cholet
The mod_perl Developer's Cookbook

The mod_perl Developer's Cookbook

By Geoffrey Young, Paul Lindner, Randy Kobes
mod_perl Pocket Reference

mod_perl Pocket Reference

By Andrew Ford
Writing Apache Modules with Perl and C

Writing Apache Modules with Perl and C

By Lincoln Stein, Doug MacEachern


Table of Contents

Description

Unfortunately for web programmers, browser bugs are not uncommon, and sometimes we have to deal with them; refer to this chapter for some known bugs and how you can work around them.



TOP

Same Browser Requests Serialization

The following feature/bug mostly affects developers.

Certain browsers will serialize requests to the same URL if accessed from different windows. For example if you have a CGI script that does:

  for (1..100) {
      print "$$: $_\n";
      warn  "$$: $_\n";
      sleep 1;
  }

And two concurrent requests are issued from different windows of the same browser (for those browsers that have this bug/feature), the browser will actually issue only one request and won't run the second request till the first one is finished. The debug printing to the error_log file helps to understand the serialization issue.

Solution? Find a UA that doesn't have this feature, especially if a command line UA will do (LWP comes to mind). As of this writing, opera 6, mozilla 1.0 on linux have this problem, whereas konqueror 3 and lynx don't.



TOP

Preventing QUERY_STRING from getting corrupted because of &entity key names

In a URL which contains a query string, if the string has multiple parts separated by ampersands and it contains a key named "reg", for example http://example.com/foo.pl?foo=bar&reg=foobar, then some browsers will interpret &reg as an SGML entity and encode it as ®. This will result in a corrupted QUERY_STRING.

The behavior is actually correct, and the problem is that you have not correctly encoded your ampersands into entities in your HTML. What you should have in the source of your HTML is http://example.com/foo.pl?foo=bar&reg=foobar.

A much better, and recommended solution is to separate parameter pairs with ; instead of &. CGI.pm, Apache::Request and $r->args() support a semicolon instead of an ampersand as a separator. So your URI should look like this: http://example.com/foo.pl?foo=bar;reg=foobar. Note that this is only an issue within HTML documents when you are building your own URLs with query strings. It is not a problem when the URL is the result of submitting a form because the browsers have to get that right. It is also not a problem when typing URLs directly into the address bar of the browser.

Reference: http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2



TOP

IE 4.x does not re-post data to a non-port-80 URL

One problem with publishing 8080 port numbers (or so I have been told) is that IE 4.x has a bug when re-posting data to a non-port-80 URL. It drops the port designator and uses port 80 anyway.

See Publishing Port Numbers other than 80.



TOP

Internet Explorer disregards your ErrorDocuments

Many users stumble upon a common problem related to MS Internet Explorer: if your error response, such as when using ErrorDocument 500 or $r->custom_response, is too short (which might often be the case because you aren't very inspired when writing error messages), Internet Explorer completely disregards it and replaces it with its own standard error page, even though everything has been sent correctly by the server and received by the browser.

The solution to this is quite simple: your content needs to be at least 512 bytes. Microsoft describes some solutions to this problem here: http://support.microsoft.com/support/kb/articles/Q294/8/07.ASP . The easiest solution under Perl is to do something like this:

  # write your HTML headers
  print "<!-- ", "_" x 513, " -->";
  # write out the rest of your HTML

Effectively, your content will be long enough, but the user won't notice any additional content. If you're doing this with static pages, just insert a long enough comment inside your file to make it large enough, which will have the same effect.



TOP

Maintainers

Maintainer is the person(s) you should contact with updates, corrections and patches.



TOP

Authors

Only the major authors are listed above. For contributors see the Changes file.






TOP
previous page: Cute Tricks With Perl and Apachepage up: Tutorialsnext page: Web Content Compression FAQ