[Showcase] [LIB] Akifox-asynchttp with SSL Support

I’ve improved my library to handle multi-platform HTTP request with a lot of new features:

  • SSL support! (cpp+neko using hxssl, java+js+flash using standard haxe)
  • Easier instances (options instead of arguments for new Request objects)
  • Better redirect handling (default max redirection set to 10 + relative redirection URLs support)
  • Custom headers on Request (cpp+neko+java only)
  • Synchronous/Asynchronous option
  • and more…

You can check it out from the official repo


If you don’t know the library the objective is about making HTTP requests easy with one API for all platforms.

This is how a minimal request looks like (but there are plenty of options if you need more control)

var request = new HttpRequest({
         url : "http://www.google.com",
    callback : function(response:HttpResponse):Void {
                if (response.isOK) {
                  trace(response.content);
                  trace('DONE (HTTP STATUS ${response.status})');
                } else {
                  trace('ERROR (HTTP STATUS ${response.status})');
                }
              }  
});

request.send();

easy!

6 Likes

Looks like a great lib… Look forward to giving it a try!

Nice one.

Ian

thanks a lot, have fun :slight_smile:

Actually I have just updated the library to version 0.4.2

That’s exactly what I was looking for! Thanks a lot!
A question:

  • Why no support for methods PUT and DELETE?

Cheers!

In javascript (HTML5) the library uses HaxeHttp to perform the request.

Sadly HaxeHttp supports only GET and POST. (don’t ask me why)
http://api.haxe.org/haxe/Http.html#request

If HaxeHttp changes and will support other methods it would be easy to implement.
Other way is to use something different from HaxeHttp.

The library is open to the second option since it uses a common “way” (like an interface) to work, and it already support 3 different ways to make a request (with the same Request object and the same Response object).
One is with Sockets (used in Java, Python and C++), which is an “complete” implementation of an Http communication.
The second is UrlLoader (used in Flash). (just wrapped to be compatible with the library Request and Response object).
The third is HaxeHttp (used in HTML5) (again, just wrapped to be compatible with the library Request and Response object).

Nothing stops adding a new fourth way, maybe a pure socket implementation for Javascript.
This surely will extend support to every method in JS also.

1 Like

Yeah, after reading HaxeHttp source I can see it has some limitations indeed.
But why not use js.html.XMLHttpRequest ?
It should be good for everything regarding JS, no?

It looks like a nice idea.
If you want to implement it, the library is open source.
Then you can make a pull request and I’ll merge it :wink:

I have no time now to try it out, but maybe in the future I will.
(I’ve opened a ticket to remember it https://github.com/yupswing/akifox-asynchttp/issues/21)

Thanks