Flash (Flex 3) Stymied by Three Digit HTTP Status Codes

Adobe's Flex 3, the language and runtime behind Flash applications on the web, has a long standing bug of not being able to process HTTP requests when the server responds with a non-200 response code.

This would be a rather serious limitation if the Flex 3 technology was intended for consuming multiple web services to bring together data available on the web in the context of an engaging and interactive user experience. Oh, wait. That is what Flex is designed for and this is a serious limitation. Flex 3 gives you the ability to do HTT, but seems to leave out the "P" for Protocol; rather inflexible, if you ask me.

And yet Flash's popularity for creating interactive page elements and Adobe's failure to fix bugs drives silliness like the following in the Twitter REST API:

suppress_response_codes: If this parameter is present, all responses will be returned with a 200 OK status code - even errors. This parameter exists to accommodate Flash and JavaScript applications running in browsers that intercept all non-200 responses. If used, it's then the job of the client to determine error states by parsing the response body. Use with caution, as those error messages may change.

It is frustrating to see a popular, but broken, client force extra work on the server side. But that's nothing new.

The response from Adobe does not leave one particularly optimistic for a quick fix (or even any fix). Here's one of the last comments on WebService fault details are hidden by Flex SDK, a bug filed in Adobe's public bug repository describing the issue:

Peter Farland - [03/03/08 02:18 PM ] Please read Matt's comment above yours... unfortunately the Flex team cannot fix this issue until the Flash Player team fixes their issue, which in turn relies on cooperation from various browsers.

Hopefully there are obscure technical reasons why it is difficult for the flash players on Firefox and Safari to pass HTTP status codes around. But you have to admit it is pretty surprising. Concerned by the comments about limitations in Firefox I verified that you can indeed access HTTP status codes and response bodies even when the response code is not 200. Here's an example that worked for me using JQuery:

        $.ajax({
            url: '/the500',
            type: 'GET',
            dataType: 'json',
            timeout: 1000,
            error: function(event, request, settings) {
                // here's the HTTP status and message from the HTTP header
                var msg = event.status + " " + event.statusText;
                // and here's the body text
                msg += " " + event.responseText.substring(0, 100);
                $('#status').text(msg);
            },
            success: function(json){
                // do something with the data.
            }
        });

Technorati Tags: ,

archived on 2009-02-11 in

blog comments powered by Disqus