foobar
foobar

Reputation: 3

HttpService question

I'm a flex noob and I have a few doubts regarding the Httpservice class,

  1. Can I use it to fetch data from a file that resides in my own server or can I use it to download any url like external sites like google or stackoverflow (even ones without an api)?

  2. Does httpservice behave differently based on whether it is an desktop app or webapp?

In short, does it behave like a httpclient(like libcurl and mechanize) or does it have restrictions(like xmlhttprequest)?

Upvotes: 0

Views: 427

Answers (3)

James Ward
James Ward

Reputation: 29433

Flex's HTTPService library is a convenience API on top of the underlying HTTP networking APIs in Flash Player. So you can only use it for things that Flash Player supports.

  1. Browsers have a same-domain / same-origin policy for network requests. So an application loaded from foo.com can only get data from foo.com. However Flash Player provides a mechanism for getting around this using crossdomain policy files. They are however dangerous and a better solution is to use a proxy like BlazeDS or Apache so that you don't violate the same-origin policy.

  2. There are some subtle differences between the HTTP networking APIs in Adobe AIR and Flash Player. One of the primary differences is that Adobe AIR applications do not have a same-origin policy.

Upvotes: 3

Rajat
Rajat

Reputation: 1125

  1. Yes you can use HttpService to fetch data from your own server.

  2. Its like XMLHttpRequest, you send requests asynchronously. For syncronous behaviour or to replicate HttpClient i think you can use the NetConnection class of ActionScript.

Upvotes: 0

Avi Flax
Avi Flax

Reputation: 51849

It's more like XmlHttpRequest. In fact it's even more limited.

Flex's HTTP support is terrible. At my firm, we classify it as a "crippled" client.

Upvotes: -1

Related Questions