MCPcopy Create free account
hub / github.com/FISCO-BCOS/FISCO-BCOS / onRead

Method onRead

bcos-boostssl/bcos-boostssl/httpserver/HttpSession.cpp:34–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 std::size_t bytes_transferred) { session->onRead(_ec, bytes_transferred); });
33}
34void bcos::boostssl::http::HttpSession::onRead(
35 boost::beast::error_code ec, std::size_t bytes_transferred)
36{
37 try
38 {
39 // the peer client closed the connection
40 if (ec == boost::beast::http::error::end_of_stream)
41 {
42 HTTP_SESSION(TRACE) << LOG_BADGE("onRead") << LOG_DESC("end of stream");
43 close();
44 return;
45 }
46
47 if (ec)
48 {
49 HTTP_SESSION(WARNING) << LOG_BADGE("onRead") << LOG_DESC("close the connection")
50 << LOG_KV("ec", ec) << LOG_KV("ec_message", ec.message());
51 close();
52 return;
53 }
54
55 if (boost::beast::websocket::is_upgrade(m_parser->get()))
56 {
57 HTTP_SESSION(INFO) << LOG_BADGE("onRead") << LOG_DESC("websocket upgrade");
58 if (m_wsUpgradeHandler)
59 {
60 m_wsUpgradeHandler(m_httpStream, m_parser->release(), nodeId());
61 }
62 else
63 {
64 HTTP_SESSION(WARNING) << LOG_BADGE("onRead")
65 << LOG_DESC(
66 "the session will be closed for "
67 "unsupported websocket upgrade");
68 close();
69 return;
70 }
71 return;
72 }
73
74 HTTP_SESSION(TRACE) << LOG_BADGE("onRead") << LOG_DESC("receive http request");
75 auto request = m_parser->release();
76 handleRequest(request);
77 }
78 catch (...)
79 {
80 HTTP_SESSION(WARNING) << LOG_DESC("onRead exception")
81 << LOG_KV("bytesSize", bytes_transferred)
82 << LOG_KV("error", boost::current_exception_diagnostic_information());
83 }
84
85 if (!m_queue.isFull())
86 {
87 read();
88 }
89}
90void bcos::boostssl::http::HttpSession::onWrite(
91 bool closeOnEOF, boost::beast::error_code ec, [[maybe_unused]] std::size_t bytes_transferred)

Callers 1

readMethod · 0.45

Calls 5

readFunction · 0.85
isFullMethod · 0.80
messageMethod · 0.45
getMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected