http.pipe should be smart enough to just work #2758
Comments
this already works with request https://github.com/mikeal/request and doesn't require a pause(). in fact a proxy is done in one line with request. this kind of high level stuff won't land in core though. |
I think that it should be possible to make it a lot better than it is today. The one-line request proxy doesn't handle websockets, or a bunch cases where write() calls can randomly throw, etc. The nodejitsu http-proxy ends up being so clumsy because it works around flaws in node's HTTP layer. Bouncy is another decent approach, but it takes on a lot of complexity (and gives up a lot of speed) by doing the HTTP parsing itself rather than leveraging node's. I don't think that the API that @AndreasMadsen presented is necessarily the best possible, but it could certainly be a lot better than what we've got. |
core should insure write does not throw, ever. pipe() in core should only work with data, i don't think core should do object capability checking for stuff like headers, and i'm a huge advocate of that style, i just don't think it belongs in core. it's another pattern that we don't see anywhere else in core, best to leave it out and let the module community define that kinda stuff. also, request's one line proxy could handle websockets, i just need to write a patch :) |
Closing this. For folks interested in passing headers + trailers, check out response-stream (which I'm sure everyone in this thread is aware of -- just leaving this as a breadcrumb for potential future readers.) |
httpStream.pipe should support headers, trailers, etc.
That would make proxy so easy that you could do: https://gist.github.com/1837361
Remember that http is a first class citizen in node town.
IRC: http://piscisaureus.no.de/log/2012-02-15#17:12:03.657
The text was updated successfully, but these errors were encountered: