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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -