How to use stream-http - 9 common examples

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 monounity / karma-typescript / tests / integration-latest / src / imports / json-import / json-import-tester.ts View on Github external
public testPackageJSON(): string {

        return require("stream-http/package").version.toString();
    }
github monounity / karma-typescript / integration-tests@latest / src / imports / json-import / json-import-tester.ts View on Github external
public testPackageJSON(): string {

        return require("stream-http/package").version.toString();
    }
github Borewit / music-metadata-browser / lib / index.spec.ts View on Github external
return new Promise(resolve => {
    http.get(url, stream => {
      resolve(stream);
    });
  });
}
github raine / ramda-cli / web / worker.js View on Github external
})
    return
  }

  if (opts.help) {
    self.postMessage({
      event: 'EVAL_OUTPUT_CHUNK',
      chunk: encode(help()),
      opts,
      firstChunk: true,
      error: false
    })
    return
  }

  evalHttpReq = http.request(
    {
      method: 'POST',
      path: '/eval',
      mode: 'prefer-streaming',
      headers: {
        'Content-Type': 'text/plain',
        'Content-Length': Buffer.byteLength(input)
      }
    },
    (res) => {
      const onStreamData = (chunk) => {
        debug('stream data')
        self.postMessage({
          event: 'EVAL_OUTPUT_CHUNK',
          chunk,
          opts,
github deanshub / web-pm2 / client / components / ActionToolbar / index.js View on Github external
showLog(logpath, id, logname) {
    this.setState({
      currentLogName: logname,
      logText: [],
    });

    let path = `/api/operations/showlog/${id}/${logname}`;
    let options = {
      path,
      method: 'GET',
    };
    let req = http.request(options, (res) => {
      this.response = res;
      res.on('data', (buf) => {
        this.setState({
          logText: this.state.logText.concat([buf.toString()]),
        });
        var objDiv = document.getElementById('logContent');
        objDiv.scrollTop = objDiv.scrollHeight;
      });
      res.on('end', () => {
        this.setState({
          logText: this.state.logText.concat(['--------------------------------------']),
        });
        var objDiv = document.getElementById('logContent');
        objDiv.scrollTop = objDiv.scrollHeight;
      });
    });

stream-http

Streaming http in the browser

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis