Category : boost-beast

After upgrading from boost 1.67.0 to boost 1.75.0, we’re having problems with boost beast’s HTTP request library. I have the following code which communicates with the Kubernetes API server to store a custom resource via the REST interface using boost beast: #include <string> #include <iostream> #include <sstream> #include <fstream> #include <boost/beast/core.hpp> #include <boost/beast/version.hpp> #include <boost/beast/http.hpp> ..

Read more

With these present in other parts of my codebase, namespace net = boost::asio; using boost::asio::ip::tcp; boost::asio::io_context& io_context_; tcp::acceptor acceptor_; void server::on_accept(boost::beast::error_code ec, boost::asio::ip::tcp::socket socket); I have noticed that this piece of code compiles: auto strand = net::make_strand(io_context_); std::shared_ptr<server> this_pointer = shared_from_this(); acceptor_.async_accept( strand, boost::beast::bind_front_handler(&server::on_accept, this_pointer) ); whereas this does not: auto strand = net::make_strand(io_context_); std::shared_ptr<server> ..

Read more

I was experimenting with boost asio with fibers and found that boost::this_fiber::yield() and boost::this_fiber::sleep_for(x) seem to behave differently when using the round robin asio scheduler provided in fibers examples. The setup is that we have one thread create two fibers which loop indefinitely: Fiber 1 uses async read with a beast websocket. while (true) { ..

Read more

I’m trying to use scio_beast in a project. I understand its rather unfinished, but that should not matter much. I’ve managed to get it working pretty well. I’m trying to connect to a server behind CloudFlare now, an I understand I need SNI for that to work. Given the following: using tcp = boost::asio::ip::tcp; // ..

Read more

I am trying boost::beast examples, I came across to this piece of code. void on_write(beast::error_code ec, std::size_t byte_transferred) { if (ec) return fail(ec, "write"); http::async_read(m_tcp_stream, m_buffer, m_response, beast::bind_front_handler( &Session::on_read, shared_from_this())); } void on_read(beast::error_code ec, std::size_t bytes_transferred) { if (ec) return fail(ec, "read"); //std::cout << m_response << std::endl; write_on_file(m_response); m_tcp_stream.socket().shutdown(tcp::socket::shutdown_both, ec); if (ec && ec != ..

Read more

// Connection establisher class class CSSLConn: public std::enable_shared_from_this<CSSLConn> { : : }; // Class for maintaining the thread pool class CHttpClient { // vector to hold connction objects std::vector <std::shared_ptr<CSSLConn>> m_sslConnObj{}; // main method call this to create connection void CHttpClient::Initialize(int nThreads) { for (int x = 0; x < nThreadCount; ++x) { worker_threads_.create_thread(boost::bind(&CHttpClient::WorkerThread, this)); ..

Read more