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:
-
if ($_SERVER[‘HTTP_HOST’] == ‘example.mydesktop’) {
-
// LOCAL DEV SETTINGS
-
} else if ($_SERVER[‘HTTP_HOST’] == ‘example.com’) {
-
// PRODUCTION SITE SETTINGS
-
}
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.
Mike :: Apr.18.2008 :: General :: No Comments »