1.0.2 • Published 7 years ago

mbed-js-http v1.0.2

Weekly downloads
13
License
-
Repository
-
Last release
7 years ago

mbed.js wrapper for mbed-http

JS on mbed driver for HTTP calls, based on sandbox/mbed-http.

This wrapper was generated via mbed-js-wrapper-generator.

Usage

  1. In your Gulp-based mbed.js project, run:

    $ npm install mbed-js-http --save
  2. Install the native library:

    $ cd node_modules/mbed-js-http
    $ mbed add $(cat mbed-http.lib)
    $ cd ../..
  3. Clear your build directory:

    $ rm -r build/out
  4. Use the library via:

    var network = /* get a network connection from somewhere... See below. */
    
    var get = HttpRequest(network, http_method.HTTP_GET, 'http://httpbin.org/status/418');
    var gres = get.send();
    
    print("Status is " + gres.status_code());

Getting a network connection

See ARMmbed/mbed-js-easy-connect.

HTTPS

This library does not support HTTPS right now. The underlying library (mbed-http) however does. I've left it out right now because:

  • HTTPS requires mbed TLS, which is relatively big, especially when combining it with JerryScript.
  • It cannot be linked out when not using it (as in C++).

If you want HTTPS:

  • Change #include http_request.h into #include https_request.h.
  • Rename all HttpRequest instances to HttpsRequest.
  • Note that the constructor for the JS object changes, so you'll need to do a little work there (one extra parameter).

Todo

  • send() is synchronous. Should not be synchronous.
  • Header allocation should be on the heap. Now the lib often runs out of stack memory when reading the headers.
1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago