File tree 2 files changed +22
-7
lines changed
2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -186,15 +186,29 @@ class hybi00 : public processor<config> {
186
186
187
187
// / Extracts requested subprotocols from a handshake request
188
188
/* *
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
190
191
*
191
192
* @param [in] req The request to extract from
192
193
* @param [out] subprotocol_list A reference to a vector of strings to store
193
194
* the results in.
194
195
*/
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 )
197
198
{
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
+ }
198
212
return lib::error_code ();
199
213
}
200
214
Original file line number Diff line number Diff line change @@ -54,20 +54,21 @@ class uri {
54
54
int state = 0 ;
55
55
56
56
it = uri_string.begin ();
57
+ size_t uri_len = uri_string.length ();
57
58
58
- if (std::equal (it,it+6 ," wss://" )) {
59
+ if (uri_len >= 7 && std::equal (it,it+6 ," wss://" )) {
59
60
m_secure = true ;
60
61
m_scheme = " wss" ;
61
62
it += 6 ;
62
- } else if (std::equal (it,it+5 ," ws://" )) {
63
+ } else if (uri_len >= 6 && std::equal (it,it+5 ," ws://" )) {
63
64
m_secure = false ;
64
65
m_scheme = " ws" ;
65
66
it += 5 ;
66
- } else if (std::equal (it,it+7 ," http://" )) {
67
+ } else if (uri_len >= 8 && std::equal (it,it+7 ," http://" )) {
67
68
m_secure = false ;
68
69
m_scheme = " http" ;
69
70
it += 7 ;
70
- } else if (std::equal (it,it+8 ," https://" )) {
71
+ } else if (uri_len >= 9 && std::equal (it,it+8 ," https://" )) {
71
72
m_secure = true ;
72
73
m_scheme = " https" ;
73
74
it += 8 ;
You can’t perform that action at this time.
0 commit comments