Skip to content

Commit b73058d

Browse files
testillanoEduardo Ramos Testillano (eramedu)
authored andcommitted
feat: add streamClose virtual callback
Add virtual streamClose(receptionId) callback invoked on successful stream close (after response is fully sent). This allows derived servers to capture the exact moment the response was committed. Also add getReceptionId() getter to Stream.
1 parent 5a89d52 commit b73058d

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

include/ert/http2comm/Http2Server.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@ class Http2Server
330330
*/
331331
virtual void streamError(uint32_t errorCode, const std::string &serverName, const std::uint64_t &receptionId, const nghttp2::asio_http2::server::request &req);
332332

333+
/**
334+
* Virtual event for successful stream close (response sent)
335+
*
336+
* @param receptionId Unique reception identifier
337+
*/
338+
virtual void streamClose(const std::uint64_t &receptionId) {;}
339+
333340
/**
334341
* Virtual dynamic response delay in milliseconds
335342
*

include/ert/http2comm/Stream.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ class Stream : public ert::queuedispatcher::StreamIf
117117
reception_id_ = id;
118118
}
119119

120+
std::uint64_t getReceptionId() const {
121+
return reception_id_;
122+
}
123+
120124
// append received data chunk
121125
void appendData(const uint8_t* data, std::size_t len);
122126

src/Http2Server.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ nghttp2::asio_http2::server::request_cb Http2Server::handler()
267267
else
268268
{
269269
stream->close();
270+
streamClose(stream->getReceptionId()); // virtual
270271
}
271272
});
272273
};

0 commit comments

Comments
 (0)