MCPcopy Create free account
hub / github.com/boostorg/beast / on_read

Method on_read

example/advanced/server-flex/advanced_server_flex.cpp:496–528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

494 }
495
496 void
497 on_read(beast::error_code ec, std::size_t bytes_transferred)
498 {
499 boost::ignore_unused(bytes_transferred);
500
501 // This means they closed the connection
502 if(ec == http::error::end_of_stream)
503 return derived().do_eof();
504
505 if(ec)
506 return fail(ec, "read");
507
508 // See if it is a WebSocket Upgrade
509 if(websocket::is_upgrade(parser_->get()))
510 {
511 // Disable the timeout.
512 // The websocket::stream uses its own timeout settings.
513 beast::get_lowest_layer(derived().stream()).expires_never();
514
515 // Create a websocket session, transferring ownership
516 // of both the socket and the HTTP request.
517 return make_websocket_session(
518 derived().release_stream(),
519 parser_->release());
520 }
521
522 // Send the response
523 queue_write(handle_request(*doc_root_, parser_->release()));
524
525 // If we aren't at the queue limit, try to pipeline another request
526 if (response_queue_.size() < queue_limit)
527 do_read();
528 }
529
530 void
531 queue_write(http::message_generator response)

Callers

nothing calls this directly

Calls 9

is_upgradeFunction · 0.85
make_websocket_sessionFunction · 0.85
releaseMethod · 0.80
failFunction · 0.70
handle_requestFunction · 0.70
do_eofMethod · 0.45
getMethod · 0.45
release_streamMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected