MCPcopy Create free account
hub / github.com/DiscordMessenger/dm / initialize_processor

Method initialize_processor

deps/websocketpp/impl/connection_impl.hpp:1131–1170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1129
1130template <typename config>
1131lib::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
1172template <typename config>
1173lib::error_code connection<config>::process_handshake_request() {

Callers 1

handle_read_handshakeMethod · 0.95

Calls 10

is_websocket_handshakeFunction · 0.85
error_codeClass · 0.85
get_websocket_versionFunction · 0.85
make_error_codeFunction · 0.50
writeMethod · 0.45
set_statusMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
replace_headerMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected