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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -