Posts RSS Comments RSS 132 Posts and 25 Comments till now

Flash for mac is bad for your HTTP_HOST

I’ve been testing the super awesome swfupload code for some projects at work.  I have nice progress bars working and you can queue up multiple files.  It’s sweet.  I tested out my code in Opera, Firefox, Safari 3, IE 7, etc on Windows and Linux.  Working great.

Of course, an hour before an important meeting is when we discover it doesn’t work on any mac browser.  The flash debug output shows our site initialization code is just throwing a fit.  No DB access settings can be found.  Doesn’t make any sense why an HTTP request from flash on a mac would break our app.

Here’s the basics of how our our setup switches dev/production settings:

  1. if ($_SERVER[‘HTTP_HOST’] == ‘example.mydesktop’) {
  2.     // LOCAL DEV SETTINGS
  3. } else if ($_SERVER[‘HTTP_HOST’] == ‘example.com’) {
  4.     // PRODUCTION SITE SETTINGS
  5. }

It makes considerations for www. etc. The problem in this case is that flash is adding :80 to the HTTP Host header. Instead of

GET /path/to/file HTTP/1.1
Host: example.com

Flash for mac likes to add

GET /path/to/file HTTP/1.1
Host: example.com:80

This will cause ‘example.com:80′ to show up in the php $_SERVER['HTTP_HOST'] variable. You can see how this would break simple host detection.

Trackback this post | Feed on Comments to this post

Leave a Reply

Comments for this post will be closed on 16 August 2008.