How to use the stream-http.get function in stream-http

To help you get started, we’ve selected a few stream-http examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PeerConnect / peer-connect / client / sockets.js View on Github external
function getTorrentFiles(torrent) {
  http.get(`/torrent/${torrent}`, function (res) {
    const data = [];

    res.on('data', function (chunk) {
      data.push(chunk);
    });

    res.on('end', function () {
      let newData = Buffer.concat(data); // Make one large Buffer of it
      let torrentParsed = parseTorrent(newData); // Parse the Buffer
      const client = new WebTorrent();
      client.add(torrentParsed, onTorrent);
    });

    //render video files to where it was specified on data-src
    function onTorrent(torrent) {
      torrent.files.forEach(function (file) {
github bipbop / harlan / src / js / app-installer.js View on Github external
inflateWorker.onmessage = ({data}) => {
        if (data === null) {
            (new Function(content.toString(encode)))();
            inflateWorker.terminate(); /* goodbye! */
            return;
        }

        decompressedSize += data.length;
        for (let i = 0; i < data.length; i++) {
            content[contentIndex++] = data[i];
        }

        updateInterfaceProgress();
    };

    streamHttp.get(path, pipe => {
        pipe.on('data', data => {
            downloadedSize += data.length;
            inflateWorker.postMessage([data, downloadedSize < compressedSize ? false : true]);
            updateInterfaceProgress();
        });
    });
})('/js/app.js.gz?h=/* @echo MD5 */', parseInt('/* @echo APP_SIZE */'), parseInt('/* @echo COMPRESSED_SIZE */'), 'utf-8');
github bipbop / harlan / src / js / app-client-installer.js View on Github external
if (data === null) {
            if (clientLoader) clientLoader.close();
            (new Function(content.toString(encode)))();
            inflateWorker.terminate(); /* goodbye! */
            return;
        }

        decompressedSize += data.length;
        for (let i = 0; i < data.length; i++) {
            content[contentIndex++] = data[i];
        }

        updateInterfaceProgress();
    };

    streamHttp.get(path, pipe => {
        pipe.on('data', data => {
            downloadedSize += data.length;
            inflateWorker.postMessage([data, downloadedSize < compressedSize ? false : true]);
            updateInterfaceProgress();
        });
    });
})('js/app-client.js.gz?h=/* @echo CLIENT_MD5 */', parseInt('/* @echo CLIENT_APP_SIZE */'), parseInt('/* @echo CLIENT_COMPRESSED_SIZE */'), 'utf-8');
github fastcast / fastcast / client / stream-torrent.js View on Github external
var parseTorrent = require('parse-torrent')
var path = require('path')
var Peer = require('simple-peer')
var prettyBytes = require('pretty-bytes')
var http = require('stream-http')
var WebTorrent = require('webtorrent')

var util = require('./util')

http.get('https://fastcast.nz/torrents/' + torrentName, function (res) {
  var data = [] // List of Buffer objects

  res.on('data', function (chunk) {
    data.push(chunk) // Append Buffer object
  })

  res.on('end', function () {
    data = Buffer.concat(data) // Make one large Buffer of it

    var torrentParsed = parseTorrent(data) // Parse the Buffer

    var client = new WebTorrent()

    client.add(torrentParsed, onTorrent)

    function onTorrent (torrent) {
github Borewit / music-metadata-browser / lib / index.spec.ts View on Github external
return new Promise(resolve => {
    http.get(url, stream => {
      resolve(stream);
    });
  });
}

stream-http

Streaming http in the browser

MIT
Latest version published 4 years ago

Package Health Score

74 / 100
Full package analysis