Settings

Theme

Show HN: httpinvoke – js HTTP client - easy progress events, binary files, etc.

github.com

28 points by tahu 12 years ago · 12 comments

Reader

tahuOP 12 years ago

Existing libraries - like jquery, reqwest and superagent - had no easy support for promises, binary files and progress events, did not support a wide range of browser versions, did not nicely treat HTTP status codes. So I made this.

antihero 12 years ago

What happens if you use this with a different promise library (e.g. bluebird)? I'm rather confused - if everything implements it's own promises, does it "just work" or do we have to worry about it all getting rather messy?

  • tahuOP 12 years ago

    Hi, thanks for the questions, sorry for the late reply..

    httpinvoke fully implements Promises/A+ specification. The spec is very short and easily implementable. The implementation in httpinvoke takes only 568bytes when minified (check it out!).

    So the answer is, if you use httpinvoke with a different promise library, it will work, unless the library really is at odds with Promises/A+ specification. Which is unlikely, because all the major promises libraries support it, even if they do not indicate that in their documentation.

    httpinvoke only contact with the external promise (which it can only get when onFulfill or onReject returns one) is the .then method here [1].

    [1] https://github.com/jakutis/httpinvoke/blob/master/src/common...

    • antihero 12 years ago

      Say, hypothetically (I haven't done any tests or anything) that Bluebird was faster than the included promise specification, is there some sort of dependency injection to replace it, seeing as it's a spec?

      • tahuOP 12 years ago

        Without a doubt Bluebird, When.js, Q, then/promise and others are faster. The implementation in httpinvoke is optimized for code size.

        The other reason for current solution is that the specification for creating and resolving promises [1] is not yet published.

        Having a Promise object in global scope, as exported by Q, Bluebird and then/promise, is not enough. There is no uniform way to hack into these implementations and use their promises resolver.

        But when resolvers-spec is available, httpinvoke will definitely check for already loaded promises library and reuse it.

        [1] https://github.com/promises-aplus/resolvers-spec

Oleg2tor 12 years ago

Simple question - how to send "application/x-www-form-urlencoded" with inputs? Why documentation miss basic things like this?

nevf 12 years ago

Are there any plans to support gzip in GET the way http-get does?

  • tahuOP 12 years ago

    Thank you! Just implemented gzip support and released 1.0.4.

dreamdu5t 12 years ago

How does this compare with superagent?

  • tahuOP 12 years ago

    httpinvoke and superagent differences:

    * superagent has a "fluent" API, httpinvoke is a plain function, with an options object and with Node.js callbacks and/or promises.

    * superagent is not easy to use with binary uploads/downloads

    * superagent does not give you an abstraction over progress events

    * httpinvoke does not build query strings

    * httpinvoke gives you raw multipart/form-data responses, does not parse them

    Other aspects are comparable (file size, Node.js and browser support, etc).

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection