Using boost::beast::websocket to send http post request

369 views Asked by At

I've got the following class member

boost::beast::websocket::stream<boost::beast::tcp_stream> ws_;

which gets instantiated on class c'tor using boost::asio::io_service as parameter.

I assume that all the websocket protocol is implemented on top of http so i was wondering if it's possible to extract the socket out of ws_ and use it to send regular http POST request ?

I've found an example that actually create the websocket out of simple tcp::socket here, so i guess it's doable, but how exactly ?

One good use-case for this for this approach is to fallback to simple HTTP requests (GET/POST) in case the websocket handshake failed (assuming it's supported by the server)

thanks

0

There are 0 answers