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
http: Make it possible to pass in a pre-existing connection #479
Conversation
1 similar comment
@laanwj sorry for the huge delay, patch LGTM, but with it That's why I hadn't merged it already. But I had an idea of how we can make it works for everybody. What do you think? |
You'll also want to set |
I figured automatic retries aren't really a possibility if the application provides the connection. This uses libevent only for the protocol handling. If the application needs retries, it has to implement them itself.
Good idea. |
I added |
1 similar comment
This patch adds functionality to pass a pre-existing connection as a bufferevent to `evhttp_connection_base_bufferevent_new`. When the bufferevent has an existing fd, the evcon starts in state `EVCON_IDLE` so that requests can be made immediately. I am using this in Bitcoin Core for doing HTTP requests over a UNIX socket (bitcoin/bitcoin#9919). It could also be useful in sandboxed environments such as cloudabi that cannot directly make connections but can pass around fds.
Suggested by Greg Hazel so the connection can read more than one request.
I'm not entirely sure what is blocking this, but will be looking at a different solution for this bypassing libevent. |
@laanwj sorry for my ignorance, last time I looked at this I did not like that this makes no-op some of functionality (evhttp_connection_set_retries), and also that fact that http layer is not in a good shape. I'm OK to merge this change if:
|
Thanks for the elaboration! I can't guarantee to get around to that but will keep it in mind. (it's not that I really insist on this solution, I just need something lightweight to connect to a HTTP server on a UNIX oscket 🙂 ) |
It may be useful to inject something into http layer indeed (and not only for unix sockets) |
This patch adds functionality to pass a pre-existing connection as a bufferevent to
evhttp_connection_base_bufferevent_new
. As far as I know, this was not possible before.When the bufferevent has an existing fd, the evcon starts in state
EVCON_IDLE
so that requests can be made immediately.I am using this in Bitcoin Core for doing HTTP requests over a UNIX socket (bitcoin/bitcoin#9919).
It could also be useful in sandboxed environments such as CloudABI that cannot directly make connections but can pass around fds.