Net: Add reactor-based HTTP server#4946
Conversation
There was a problem hiding this comment.
Interesting, thank you. I tried to do it long time ago but it was never finished/merged.
I did not yet have time for a thorough review, but in principle I would welcome this contribution.
While at it, you may also want to replace the NotificationCenter with AsyncNotificationCenter - it's a drop-in replacement that should work out of the box. See #4414 and #4851 for the reason.
Oh yes, please write some unit tests. And see CodingStyle.
Net/include/Poco/Net/HTTPObserver.h
Outdated
| namespace Net { | ||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Coding style:
- remove indentation for the second namespace
- remove blank line between namespaces
- there should be only two blank lines after second namespace
| }; | ||
|
|
||
| } | ||
| }; No newline at end of file |
| } | ||
| } | ||
|
|
||
| #endif // Net_HTTPReactorServerSession_INCLUDED No newline at end of file |
| } | ||
|
|
||
|
|
||
| #endif No newline at end of file |
| } // namespace Net | ||
| } // namespace Poco | ||
|
|
||
| #endif // Net_TCPReactorServer_INCLUDED No newline at end of file |
Net/src/HTTPReactorServer.cpp
Outdated
| #include <cstring> | ||
|
|
||
| namespace Poco { | ||
| namespace Net { |
Net/src/HTTPReactorServer.cpp
Outdated
| _tcpReactorServer.stop(); | ||
| } | ||
|
|
||
| void HTTPReactorServer::onMessage(const TcpReactorConnectionPtr & conn) { |
There was a problem hiding this comment.
style: opening brace in new line
| response.setVersion(request.getVersion()); | ||
| response.setKeepAlive( request.getKeepAlive() && session.canKeepAlive()); | ||
| try | ||
| { |
There was a problem hiding this comment.
style:
- space/tab indentation mix
- too much indentation
| void setReactorMode(bool reactorMode); | ||
| /// Sets the reactor mode. | ||
| /// | ||
| /// If true, use reactor mode, else use thread pool mode. |
There was a problem hiding this comment.
style: there should be a blank line between comment and the next function
OK! |
0a60c52 to
aeb05c0
Compare
|
@sky92zwq , many of the tests fail. Please check the logs and correct the code. |
|
@matejk I have added some commits, but I don't have a Windows compilation environment locally. May this pull request (PR) automatically trigger the workflow? |
|
@sky92zwq, do you have anything to add for this PR. If not, I'd merge it to main branch. |
Thanks for checking in, nothing else from me right now. We can move forward and address any new cases that arise later. |
While developing an HTTP framework based on POCO for my client, I realized POCO didn't provide an implementation of a reactor HTTP server. So I decided to implement a reactor HTTP server. There aren't too many differences between HTTP servers and HTTP reactor servers from the user's perspective. I just added several TCP parameters and changed the HTTP server to an HTTP reactor server, which is shown in the example HTTPReactorTime.
I later found some similar work [here](#2093). I may have duplicated some effort.
If anyone is interested in this, please let me know.