Use HTTP keep-alive #137

Open
opened 2026-10-05 04:00:51 +02:00 by adam · 7 comments
Owner

Current code doesn't allow to do interesting stuff, because every HTTP request is parsed only from beginning of the connection.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/650-use-http-keep-alive?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github).
Current code doesn't allow to do interesting stuff, because every HTTP request is parsed only from beginning of the connection. ## <bountysource-plugin> --- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/650-use-http-keep-alive?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1759&utm_medium=issues&utm_source=github). </bountysource-plugin> <!-- github-sync-id:6176039 -->
Author
Owner

Define "interesting stuff", please (and how keep-alive helps with it)

Define "interesting stuff", please (and how keep-alive helps with it) <!-- github-comment-id:7674224 -->
Author
Owner

I want a module to use long polling for its web needs.
If to use OnWebPreRequest and send Connection: keep-alive myself without closing the socket, browser will see the open socket, and will send through it not only request related to the module, but to the whole ZNC.

Also there's no good way to read from the socket, which wasn't closed via returning true from OnWebPreRequest(), because ZNC is event-driven, and such socket doesn't notify my module about new data.

Moving support for keep-alive to core would help, it'll just do OnWebRequest() on the module not only on new connections, but on old ones too.

I want a module to use long polling for its web needs. If to use OnWebPreRequest and send Connection: keep-alive myself without closing the socket, browser will see the open socket, and will send through it not only request related to the module, but to the whole ZNC. Also there's no good way to read from the socket, which wasn't closed via returning true from OnWebPreRequest(), because ZNC is event-driven, and such socket doesn't notify my module about new data. Moving support for keep-alive to core would help, it'll just do OnWebRequest() on the module not only on new connections, but on old ones too. <!-- github-comment-id:7674344 -->
Author
Owner

Even if it's not real "long polling"...

Even if it's not real "long polling"... <!-- github-comment-id:7674360 -->
Author
Owner

How about this: Return true from OnWebPreRequest() and use the socket manager's SwapSockByAddr() to replace the HTTP socket with your own code.

How about this: Return true from OnWebPreRequest() and use the socket manager's SwapSockByAddr() to replace the HTTP socket with your own code. <!-- github-comment-id:7674643 -->
Author
Owner

It doesn't stop browser to do requests via this connection unrelated to my module.
Browsers don't know that this connection is only for that ZNC module, they just see site name.

It doesn't stop browser to do requests via this connection unrelated to my module. Browsers don't know that this connection is only for that ZNC module, they just see site name. <!-- github-comment-id:7674685 -->
Author
Owner

Uhm, just don't send back a keep-alive header. Just "replying slowly" should already work fine, shouldnt it?

Uhm, just don't send back a keep-alive header. Just "replying slowly" should already work fine, shouldnt it? <!-- github-comment-id:7674752 -->
Author
Owner

dd576a0ccdf625c2df806a2e43cead1c60d41dae

dd576a0ccdf625c2df806a2e43cead1c60d41dae <!-- github-comment-id:7675579 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#137