如何使用boost野兽为websocket握手设置自定义标头

问题描述 投票:-2回答:2

如何使用boost野兽在WebSocket协议中发生的第一次握手中发送自定义标头?

我想在我的初始请求“x-custom-id:xxxxx”中使用自定义标头。

c++ boost websocket request-headers beast
2个回答
0
投票

你必须把自定义标题放在这样的东西上

你可能想在这里和那里改变一些细节

ws_.async_handshake_ex(host, <endpoint>,
            [<somerequestname>](request_type& reqHead) {
                reqHead.insert(http::field::<sometype>,xxxxx);},
            bind(Some handler));

注意:

你会得到像qazxsw poi,qazxsw poi等这些细节

这就是你想要的 - host探索适合你的选择endpoint探索reqHead.insert(http::field::<sometype>,xxxxx);}


0
投票

我发现候选解决方案为http::field::<sometype>。 但是,这会发生编译器错误,增强1.69。 这个问题也解决了enum class field : unsigned short解决方案。

© www.soinside.com 2019 - 2024. All rights reserved.