Skip to content

Commit 09de1a3

Browse files
committed
Incorporating feedback on websocket subprotocol implementation.
1 parent 4e50432 commit 09de1a3

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

Release/src/websockets/client/ws_client.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ namespace client
8080
namespace details
8181
{
8282

83+
static utility::string_t g_subProtocolHeader(_XPLATSTR("Sec-WebSocket-Protocol"));
84+
8385
class ws_desktop_client : public _websocket_client_impl, public std::enable_shared_from_this<ws_desktop_client>
8486
{
8587
private:
@@ -278,18 +280,17 @@ class ws_desktop_client : public _websocket_client_impl, public std::enable_shar
278280
}
279281

280282
// Add any request headers specified by the user.
281-
const utility::string_t protocolHeader(_XPLATSTR("Sec-WebSocket-Protocol"));
282283
const auto & headers = m_client_config.headers();
283284
for (const auto & header : headers)
284285
{
285-
if (!utility::details::str_icmp(header.first, protocolHeader))
286+
if (!utility::details::str_icmp(header.first, g_subProtocolHeader))
286287
{
287288
con->append_header(utility::conversions::to_utf8string(header.first), utility::conversions::to_utf8string(header.second));
288289
}
289290
}
290291

291292
// Add any specified subprotocols.
292-
if (headers.has(protocolHeader))
293+
if (headers.has(g_subProtocolHeader))
293294
{
294295
const std::vector<utility::string_t> protocols = m_client_config.subprotocols();
295296
for (const auto & value : protocols)

Release/src/websockets/client/ws_msg.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ void websocket_client_config::add_subprotocol(const ::utility::string_t &name)
5555
std::vector<::utility::string_t> websocket_client_config::subprotocols() const
5656
{
5757
std::vector<::utility::string_t> values;
58-
if (m_headers.has(g_subProtocolHeader))
58+
auto subprotocolHeader = m_headers.find(g_subProtocolHeader);
59+
if (subprotocolHeader != m_headers.end())
5960
{
60-
utility::stringstream_t header(m_headers.find(g_subProtocolHeader)->second);
61+
utility::stringstream_t header(subprotocolHeader->second);
6162
utility::string_t token;
6263
while (std::getline(header, token, U(',')))
6364
{

Release/src/websockets/client/ws_winrt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "stdafx.h"
2828
#include <concrt.h>
2929

30-
// ws_winrt only available for windows store app or window phone 8.1
30+
// ws_winrt only available for Windows Store apps and Windows Phone 8.1
3131
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP) || (WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) && _WIN32_WINNT == _WIN32_WINNT_WINBLUE)
3232

3333
using namespace ::Windows::Foundation;

Release/tests/Functional/websockets/utilities/test_websocket_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace utilities {
155155

156156
test_websocket_msg wsmsg;
157157

158-
wsmsg.set_data(std::vector<unsigned char>(pay.begin(), pay.end()));
158+
wsmsg.set_data(std::vector<uint8_t>(pay.begin(), pay.end()));
159159

160160
switch (msg->get_opcode())
161161
{

Release/tests/Functional/websockets/utilities/test_websocket_server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ enum test_websocket_message_type
5757
class test_http_request_interface
5858
{
5959
public:
60+
virtual ~test_http_request_interface() {}
6061
virtual const std::string& username() = 0;
6162
virtual const std::string& password() = 0;
6263
virtual const std::string& get_header_val(const std::string& header_name) = 0;

0 commit comments

Comments
 (0)