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

Method on_read

example/advanced/server/advanced_server.cpp:389–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

387 }
388
389 void
390 on_read(beast::error_code ec, std::size_t bytes_transferred)
391 {
392 boost::ignore_unused(bytes_transferred);
393
394 // This means they closed the connection
395 if(ec == http::error::end_of_stream)
396 return do_close();
397
398 if(ec)
399 return fail(ec, "read");
400
401 // See if it is a WebSocket Upgrade
402 if(websocket::is_upgrade(parser_->get()))
403 {
404 // Create a websocket session, transferring ownership
405 // of both the socket and the HTTP request.
406 std::make_shared<websocket_session>(
407 stream_.release_socket())->do_accept(parser_->release());
408 return;
409 }
410
411 // Send the response
412 queue_write(handle_request(*doc_root_, parser_->release()));
413
414 // If we aren't at the queue limit, try to pipeline another request
415 if (response_queue_.size() < queue_limit)
416 do_read();
417 }
418
419 void
420 queue_write(http::message_generator response)

Callers

nothing calls this directly

Calls 7

is_upgradeFunction · 0.85
releaseMethod · 0.80
failFunction · 0.70
handle_requestFunction · 0.70
getMethod · 0.45
do_acceptMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected