Skip to content
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.

Cordova HTTP plugin using Node.js http module interface

License

Notifications You must be signed in to change notification settings

nicomt/cordova-plugin-node-http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova Node HTTP: Node API HTTP plugin for Android

This module is an implementation of Node's native http module for Cordova on Android. It tries to match Node's API and behavior as closely as possible, but is still a work in progress and some features are not supported.

Like cordova-plugin-advanced-http this plugin tries to avoid limitations with browser implementations like forced CORS and missing client certificate authentication, but it improves on it by using Node.js stream implementation, to allow for requests of virtually any size, as well as the resuse of existing libraries built for Node.js

Installation

This plugin is published on NPM and can be installed using Cordova CLI

cordova plugin add cordova-plugin-node-http

Usage

The intent is to have the same API as the client part of the Node HTTP module. The interfaces are the same wherever practical.

This module implements http.request, http.get, and most of http.ClientRequest and http.IncomingMessage, in addition to http.METHODS, http.STATUS_CODES and some https options (ca, cert and key). See the Node docs for how these work.

Features missing compared to Node

  • http.createServer is not supported // TODO document other missing features

Simple Example

const http = window.CordovaNodeHttp;

http.get('https://jsonplaceholder.typicode.com/users', function (res) {

    let users = '';

    res.on('data', function (buf) {
        users += buf.toString('utf8');
    });

    res.on('end', function () {
        console.log(users)
    });
})

About

Cordova HTTP plugin using Node.js http module interface

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published