HTTPService - how to detect redirection

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

HTTPService - how to detect redirection

OmPrakash Muppirala
I have a sticky problem where I need to make a call to RESTful webservice -
which by design redirects to another url.  The response payload is being
retrieved fine, but there is a transaction id that is being passed in the
redirected url.  I need this transaction id to do further operations.

HTTPService is following the 303 redirect, but when I inspect the
ResultEvent object, the url is the original url, and not the redirected
url.  I am listening to the HTTPStatusEvent.HTTP_RESPONSE_STATUS event, but
it never fires.

I tried switching to the HttpClient API provided by the AS3 HttpClient
project [1] but the problem there is it tells me about the redirect
location (via the header), but it does not folow the redirection.

Is there any way to find the redirected url using HTTPService?  Or if
anyone can suggest an alternative approach, that would be great as well.

Here is the relevant code:

                var service:HTTPService = new HTTPService();
>                 service.resultFormat = HTTPService.RESULT_FORMAT_E4X;
>                 service.url = url;
>                 service.showBusyCursor = true;
>                 service.addEventListener(ResultEvent.RESULT,
> resultHandler);
>
> service.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,handleHttpServiceStatus);
>                 service.send();
>

Thanks,
Om

[1] http://code.google.com/p/as3httpclient/