MCPcopy Create free account
hub / github.com/acl-dev/acl / upgradeWebsocket

Function upgradeWebsocket

lib_acl_cpp/src/http/HttpServlet.cpp:109–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109static bool upgradeWebsocket(HttpServletRequest& req, HttpServletResponse& res)
110{
111 const char* ptr = req.getHeader("Connection");
112 if (ptr == NULL) {
113 return false;
114 }
115 if (acl_strcasestr(ptr, "Upgrade") == NULL) {
116 return false;
117 }
118 ptr = req.getHeader("Upgrade");
119 if (ptr == NULL) {
120 return false;
121 }
122 if (strcasecmp(ptr, "websocket") != 0) {
123 return false;
124 }
125 const char* key = req.getHeader("Sec-WebSocket-Key");
126 if (key == NULL || *key == 0) {
127 logger_warn("no Sec-WebSocket-Key");
128 return false;
129 }
130
131 http_header& header = res.getHttpHeader();
132 header.set_upgrade("websocket");
133 header.set_ws_accept(key);
134 return true;
135}
136
137bool HttpServlet::start(void)
138{

Callers 1

startMethod · 0.85

Calls 2

acl_strcasestrFunction · 0.85
getHeaderMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…