| 1129 | |
| 1130 | template <typename config> |
| 1131 | lib::error_code connection<config>::initialize_processor() { |
| 1132 | m_alog->write(log::alevel::devel,"initialize_processor"); |
| 1133 | |
| 1134 | // if it isn't a websocket handshake nothing to do. |
| 1135 | if (!processor::is_websocket_handshake(m_request)) { |
| 1136 | return lib::error_code(); |
| 1137 | } |
| 1138 | |
| 1139 | int version = processor::get_websocket_version(m_request); |
| 1140 | |
| 1141 | if (version < 0) { |
| 1142 | m_alog->write(log::alevel::devel, "BAD REQUEST: can't determine version"); |
| 1143 | m_response.set_status(http::status_code::bad_request); |
| 1144 | return error::make_error_code(error::invalid_version); |
| 1145 | } |
| 1146 | |
| 1147 | m_processor = get_processor(version); |
| 1148 | |
| 1149 | // if the processor is not null we are done |
| 1150 | if (m_processor) { |
| 1151 | return lib::error_code(); |
| 1152 | } |
| 1153 | |
| 1154 | // We don't have a processor for this version. Return bad request |
| 1155 | // with Sec-WebSocket-Version header filled with values we do accept |
| 1156 | m_alog->write(log::alevel::devel, "BAD REQUEST: no processor for version"); |
| 1157 | m_response.set_status(http::status_code::bad_request); |
| 1158 | |
| 1159 | std::stringstream ss; |
| 1160 | std::string sep; |
| 1161 | std::vector<int>::const_iterator it; |
| 1162 | for (it = versions_supported.begin(); it != versions_supported.end(); it++) |
| 1163 | { |
| 1164 | ss << sep << *it; |
| 1165 | sep = ","; |
| 1166 | } |
| 1167 | |
| 1168 | m_response.replace_header("Sec-WebSocket-Version",ss.str()); |
| 1169 | return error::make_error_code(error::unsupported_version); |
| 1170 | } |
| 1171 | |
| 1172 | template <typename config> |
| 1173 | lib::error_code connection<config>::process_handshake_request() { |
no test coverage detected