Comments (9)
meh not a big deal. ideally, it should only check for res
. it may work for requests and req
but i haven't tested that yet
from on-finished.
Only accepting res
is the only good way to do #4, which is why I ask. If you read the internal implementation of req
and res
, you'll see what I mean.
from on-finished.
it may work for requests and req but i haven't tested that yet
it does work, because this modules does thingie.res
, which translates to req.res
, and thus works, weirdly.
from on-finished.
hmmm i guess it doesn't then because you want to listen to finish
on the req
:
var req = http.request({
method: 'POST',
path: '/upload'
})
var stream = fs.createReadStream('filename')
stream.pipe(req)
finished(req, function () {
stream.destroy()
})
from on-finished.
Right. This module, as it is right now, only allows you to act when the response is finished. AFAIK this will also mean the request is finished, but I'm not sure. But you cannot actually pass in req
, since it'll just add all the listeners on res
anyway...
from on-finished.
I first noticed this because I couldn't use finished
with body-parser
, since it wouldn't fire until after the response was finished, but I wanted something that would first after the req
was finished.
Does it seem desirable that we wait for whatever is passed in to finish, instead of switching to an existing res
property? This would mean koa
cannot pass in the ctx
variable directly, it would need to change to do ctx.res
.
from on-finished.
Does it seem desirable that we wait for whatever is passed in to finish, instead of switching to an existing res property?
ya
from on-finished.
It looks like if this were changed, the koa
example would become:
function* () {
var stream = this.body = fs.createReadStream('thingie.json')
onFinished(this.res, function (err) {
stream.destroy()
})
}
i.e. this
-> this.res
from on-finished.
yeah that's fine
from on-finished.
Related Issues (20)
- client-side timeout can not be detected. HOT 6
- Return listener-remover instead of response. HOT 1
- Call in LIFO order instead of FIFO HOT 2
- LIFO instead of FIFO HOT 3
- fires before the end of the response HOT 7
- EventEmitter raises a warning about potential memory leak when using on-finished with HTTP2 connections HOT 5
- write EPIPE HOT 6
- unregister listener HOT 1
- Response Body missing After on-finished called HOT 6
- http2 compat tests HOT 1
- Test failed on node version 10 and 11 HOT 6
- isFinished incorrect? HOT 8
- on-finished vs Node stream.finished() HOT 2
- Callback fires immediatly on sendFile HOT 17
- Pipelining and Socket handlers HOT 4
- Grammatical error in Readme.md file HOT 2
- async hooks compatibility? HOT 3
- Module not found: Error: Can't resolve 'async_hooks' HOT 5
- Broken tests for Node@8 and Node@9 #159 HOT 1
- Broken tests for Node@8 and Node@9 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from on-finished.