开发者

How can I retrieve the body of an HTTP 403 with Flash?

I'm having a heck of a time trying to figure this one out.

I've got a simple YouTube API client put together, written in Flex, that uses a plain ol' URLRequest object to handle Google's "ClientLogin" authentication scheme. Everything works perfectly, except for one case: when Google responds with a 403 and a response body indicating that I should prompt the user for additional information (specifically, a CAPTCHA request).

The problem I'm having is that in this case, I need to be able to retrieve the body of the 403 response, as the body contains information Google expects me to use to assemble the CAPTCHA (e.g., an image URL, etc.). It looks like Flash fails to populate the URLLoader's data property when it encounters a 403 (which is where the response body would normally show up), so I can't tell the difference between a "403: Login Failed" and a "403: Login Succeeded, but We Want a CAPTCHA".

As a backup, I figured I'd have a look at as3crypto's TLSSocket code, but I haven't been able to make any of that stuff work with Google (or even one of my own SSL certs, for that matter).

开发者_如何学JAVA

So my question is twofold:

  1. Is it possible to access the body of a 403 response with Flash (and if so, how)? And if not,
  2. Does anyone have personal experience with a suitable workaround?

Many thanks in advance -- I'm pretty much stuck on this one.


You can get the response by using HTTPService instead of URLLoader. HTTPService loads the response even in cases of any status code (200, 404, 403 etc.). I've been using it for quite some time.

PS: I use this in Picasa Web APIs for user-authentication.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜