Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

http.pipe should be smart enough to just work #2758

Closed
AndreasMadsen opened this issue Feb 15, 2012 · 5 comments
Closed

http.pipe should be smart enough to just work #2758

AndreasMadsen opened this issue Feb 15, 2012 · 5 comments
Labels

Comments

@AndreasMadsen
Copy link
Member

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

@mikeal
Copy link

mikeal commented Feb 16, 2012

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.

@AndreasMadsen
Copy link
Member Author

@mmalecki @isaacs any thoughts on this, I'm not much intro the http-proxy-server stuff I just opened the issue.

@isaacs
Copy link

isaacs commented Feb 16, 2012

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.

@mikeal
Copy link

mikeal commented Feb 16, 2012

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 :)

@chrisdickinson
Copy link

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.)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants