Tuesday, July 08, 2008

The Truth about Flex HTTPService

So I have unraveled the Truth. (I think)

It's more tortured than one would imagine

1/ All HTTP GET requests are stripped of headers. It's not in the Flex stack so it's probably the underlying Flash player runtime

2/ All HTTP GET requests that have content type other than "application/x-www-form-urlencoded" are turned into POST requests

3/ All HTTP POST requests that have no actual posted data are turned into GET requests. See 1/ and 2/

4/ All HTTP PUT and HTTP DELETE requests are turned into POST requests. This appears to be a browser limitation that the Flash player is stuck with.

What this boils down to in practical terms is that if you want to pass headers in all requests, you should always use POST and you should find another way to communicate the semantics of the operation you "really wanted". The Rails community have settled on passing ?_method=PUT/DELETE as a work around for the browser problems underlying 4/

Since Flash adds the wonderful header stripping pain on GET, I'm also using ?_method=GET as a workaround for that. However, since this trips up on 3/,
I am passing a dummy object as the encoded POST data. Which means my service needs to ignore dummy posted data on a ?_method=GET request.

Crucial at this point to know about 2/. That wasted a bunch of my time.

I've built all of this handling into a new RESTService class with MXML markup support so it's possible to pretend this doesn't exist on the client side.

Hope this helps someone.


  1. this definitely helped me! Thanks a bunch for sharing. I was fighting it looking at every possible detail! I don't know why the documentation of HttpService in liveDocs doesn't make any mention of this; because it really makes the PUT/DELETE useless! or am I missing something!

  2. Beakman2:22 PM

    The contentType issue for POST's being sent as GET's was driving me crazy. Thanks for posting this info!

  3. Anonymous1:30 AM

    Thanks a ton, this was driving me nuts.

  4. It's a pain in the ass, but I'm glad you laid it out. Thanks

  5. Anonymous5:34 AM

    Thanks a lot, I wasted so much time with empty Post request being Get request

  6. Anonymous5:47 AM


  7. Sonofa-- that's terrible. How on earth has that survived in the API? Thanks for uncovering this and saving me hours of hair-pulling.

  8. good info, I re-posted on my wiki just in case you take your site down one day (credit is given/linked to you):

  9. One more stupid bug from Adobe. Helpful post. Many thanks!

  10. Thanks man, that was really helpful!

  11. Three years later that bug still isn’t fixed - but yay, thx for that piece of information!!

  12. Hey all, I work on a big flex project for Franklin Covey. We use REST services. In order to support this. We created a XMLHttpRequest wrapper. By using external interface with some event handlers. We opensourced the library. You can check it out at