How to use the stream-http.request 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 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