You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the goal of supporting to stream JSON responses to clients in the fly (#10407), it would be nice if that could be done still using the central request/response handling. At the moment, it's already possible to take over a whole HTTP connection and start streaming a response, like it's done for the event streams at the moment:
However, it would be nicer if it was possible for normal request handlers to just start writing a response, similar to how it's done in Go with http.ResponseWriter. In contrast, what's currently in Icinga 2 is more similar to http.Hijacker.
However, before doing bigger changes to the connection handling, I'd propose to reevaluate how we are handling HTTP connections at the moment. In particular, we already make use of Boost Beast, a HTTP library, so do we actually need to implement the following connection handling loop ourselves or does the library maybe even provide something better out of the box?
if (!ProcessRequest(*m_Stream, request, authenticatedUser, response, *this, m_HasStartedStreaming, cpuBoundWorkTime, yc)) {
break;
}
if (request.version() != 11 || request[http::field::connection] == "close") {
break;
}
}
} catch (const std::exception& ex) {
if (!m_ShuttingDown) {
Log(LogWarning, "HttpServerConnection")
<< "Exception while processing HTTP request from " << m_PeerAddress << ": " << ex.what();
}
}
Disconnect(yc);
}
Depending on the answer, options for going further could adapting our existing code, or replacing it with what the library provides.
refs #10142 (consider that when changing the implementation, maybe this can be solved in one go or it even becomes obsolete when switching to library functions)
The text was updated successfully, but these errors were encountered:
In particular, we already make use of Boost Beast, a HTTP library, so do we actually need to implement the following connection handling loop ourselves or does the library maybe even provide something better out of the box?
This library is not a client or server, but it can be used to build those things. Many examples are provided, including clients and servers, which may be used as a starting point for writing your own program.
I've also browsed the documentation and the answer is, no, the library doesn't provide such helper implementations.
With the goal of supporting to stream JSON responses to clients in the fly (#10407), it would be nice if that could be done still using the central request/response handling. At the moment, it's already possible to take over a whole HTTP connection and start streaming a response, like it's done for the event streams at the moment:
icinga2/lib/remote/eventshandler.cpp
Lines 103 to 131 in 8d607d2
However, it would be nicer if it was possible for normal request handlers to just start writing a response, similar to how it's done in Go with
http.ResponseWriter
. In contrast, what's currently in Icinga 2 is more similar tohttp.Hijacker
.However, before doing bigger changes to the connection handling, I'd propose to reevaluate how we are handling HTTP connections at the moment. In particular, we already make use of Boost Beast, a HTTP library, so do we actually need to implement the following connection handling loop ourselves or does the library maybe even provide something better out of the box?
icinga2/lib/remote/httpserverconnection.cpp
Lines 466 to 567 in 8d607d2
Depending on the answer, options for going further could adapting our existing code, or replacing it with what the library provides.
refs #10142 (consider that when changing the implementation, maybe this can be solved in one go or it even becomes obsolete when switching to library functions)
The text was updated successfully, but these errors were encountered: