-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
connect-injector does not work with node 0.11 and express.compress() #7
Comments
For a reference I'm attaching my fix, but it is not very elegant. I'm not familiar with uberproto, it may allow a much nicer way to fix the problem. |
(until daffl/connect-injector#7 is fixed)
The same problem happens with node 0.10 when
This returns an empty response if the line marked 'XXX' is enabled. The problem is that the Broken |
Unit tests that access modified response body fail (the body is missing). It can be reproduced with:
I identified the error to be in this line https://github.com/daffl/connect-injector/blob/master/lib/connect-injector.js#L151.
The line assumes that a call to
super(data)
, will not invokewrite(data)
. This assumption was true in node 0.10end(data)
outputs data directly to an outgoing connection (https://github.com/joyent/node/blob/v0.10/lib/http.js#L959). But with node 0.11end(data)
, delegates this job towrite(data)
(https://github.com/joyent/node/blob/master/lib/_http_outgoing.js#L524).This causes injector's mixed in
write(data)
to be invoked again, and the data is buffered and never passed to the original handler.A fix would be to replace the call to
super(data)
withoriginal_handler.write(data)
, followed bysuper()
(with no data passed). I tried an ugly way of saving the original write function:and this fixed the tests. I'm not sure though that this is fully correct, maybe there is a nicer way that allows somehow to refer to
write._super()
fromend()
?The text was updated successfully, but these errors were encountered: