Reference: websocket_client_sync.cpp
Table 1.30. WebSocket HTTP Upgrade Request
GET / HTTP/1.1
Host: www.example.com
Upgrade: websocket
Connection: upgrade
Sec-WebSocket-Key: 2pGeTR0DsE4dfZs2pH+8MA==
Sec-WebSocket-Version: 13
User-Agent: Boost.Beast/216
Question> Based on the example websocket_client_sync.cpp
, which function is used to send a HTTP Upgrade Request similar as the one shown above and how can I print the request shown above?
Thank you
This is a duplicate, but I can't mark it as such because this answer was never accepted¹:
boost async ws server checking client information
In short use the overload of accept that that takes a request object that you have previously read.
The linked answer has a complete live demo.
¹ answering on Stack overflow can be pretty thankless at times
UPDATE
To the comment, I apologize for missing the client/server distinction initially. The client has a similar overload on
handshake
that allows you to inspect the upgrade response:Printing e.g.
However, the request is not directly exposed. I suppose it's best monitored with a network packet sniffer or from the server side. If the goal is to manipulate the upgrade request, you should use a
RequestDecorator
.PS: I just checked and the request decorator is applied nearly-at-the-end (although some things related to per-message-deflate might be added on later in the
handshake_op
). So you might be content with just supplying a decorator that inspects the request:Which prints e.g.