node.js - koa.js streaming response from remote url -


i want create koa route acts proxy url, delivers file few dozens of megabytes.

therefore not block when making response. using this.body = yield request.get(url); currently, request [co-request]1 module.

how stream response client ?

edit :

i doing following :

var req = require('request'); //... this.body = req(url).pipe(fs.createwritestream(this.params.what)); 

if paste url in browser, file fine. if error: cannot pipe. not readable. in route.

turns out solution :

var req = require('request'); //... this.body = req(url); 

this because this.body has readable stream, req(url) returns. @danneu explanation.


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -