Skip to content

Commit e6f8766

Browse files
author
Lukas Obermann
committed
added subprotocol support for hybi00 / hixie76
This was missing but it is described in the RFC here https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-1.9
1 parent 17a2647 commit e6f8766

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

websocketpp/processors/hybi00.hpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,29 @@ class hybi00 : public processor<config> {
186186

187187
/// Extracts requested subprotocols from a handshake request
188188
/**
189-
* hybi00 doesn't support subprotocols so there never will be any requested
189+
* hybi00 does support subprotocols
190+
* https://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00#section-1.9
190191
*
191192
* @param [in] req The request to extract from
192193
* @param [out] subprotocol_list A reference to a vector of strings to store
193194
* the results in.
194195
*/
195-
lib::error_code extract_subprotocols(request_type const &,
196-
std::vector<std::string> &)
196+
lib::error_code extract_subprotocols(request_type const & req,
197+
std::vector<std::string> & subprotocol_list)
197198
{
199+
if (!req.get_header("Sec-WebSocket-Protocol").empty()) {
200+
http::parameter_list p;
201+
202+
if (!req.get_header_as_plist("Sec-WebSocket-Protocol",p)) {
203+
http::parameter_list::const_iterator it;
204+
205+
for (it = p.begin(); it != p.end(); ++it) {
206+
subprotocol_list.push_back(it->first);
207+
}
208+
} else {
209+
return error::make_error_code(error::subprotocol_parse_error);
210+
}
211+
}
198212
return lib::error_code();
199213
}
200214

0 commit comments

Comments
 (0)