1. @webtorrent/http-node
Node.js http as a standalone package
@webtorrent/http-node
Package: @webtorrent/http-node
Created by: webtorrent
Last modified: Thu, 07 Apr 2022 12:31:05 GMT
Version: 1.3.0
License: MIT
Downloads: 11,136
Repository: https://github.com/webtorrent/http-node

Install

npm install @webtorrent/http-node
yarn add @webtorrent/http-node

http-node

This module is a standalone package of http from Node.js v6.3.0.
Unlike http-browserify, this is not a shim but the original code of Node.js, so it requires the net module.
This is useful for having the Node.js core APIs on JavaScript platforms other than Node.js, where TCP sockets are available (which can be wrapped in a net module).
One example of this is Chrome Apps with chrome-net.

install / usage with browserify

 npm install http-node

To use it with browserify, you have to use the JS API of browserify;
the command line API does not support changing builtins.

Example:

 const browserify = require('browserify');

const builtins = require('browserify/lib/builtins.js');
var customBuiltins = Object.assign({}, builtins);
customBuiltins.http = require.resolve('http-node');

var b = browserify({builtins: customBuiltins});

b.add(...

differences to original Node.js code

  • require calls of _http_* modules prefixed with ./
  • require('internal/util').deprecate replaced by require('util').deprecate
  • uses http-parser-js
  • commented out calls to DTRACE_HTTP_*, LTTNG_HTTP_* and COUNTER_HTTP_*
  • does not presume that sockets have a _handle

credit

The code is taken from the Node.js project:

Copyright Node.js contributors. All rights reserved.

license

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code