flatiron/union — pull request #39 by travist (2012-09-16 00:51:26+00:00)
Title: Sessions are not saved when using Connect.session() middleware.

I am working on getting FlatIron to play nicely with Passport.js with https://github.com/travist/flatiron-passport.

I noticed that the session saving fails with OAuth because https://github.com/senchalabs/connect/blob/master/lib/middleware/session.js#L274 tries to inject itself before the end method is called. However this is attached to the ```this``` pointer of the request object and not ```this.res```.

This can all be fixed if we just check to see if the ```end``` method is attached to ```this```, and call it instead if it is... If not, then fallback to current behavior.