MCPcopy Create free account
hub / github.com/IronsDu/brynet / ProcessHttp

Method ProcessHttp

include/brynet/net/http/HttpService.hpp:348–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346 }
347
348 static size_t ProcessHttp(const char* buffer,
349 size_t len,
350 const HTTPParser::Ptr& httpParser,
351 const HttpSession::Ptr& httpSession)
352 {
353 size_t retlen = len;
354 if (!httpParser->isCompleted())
355 {
356 retlen = httpParser->tryParse(buffer, len);
357 if (!httpParser->isCompleted())
358 {
359 return retlen;
360 }
361 }
362
363 if (httpParser->isWebSocket())
364 {
365 if (httpParser->hasKey("Sec-WebSocket-Key"))
366 {
367 auto response = WebSocketFormat::wsHandshake(
368 httpParser->getValue("Sec-WebSocket-Key"));
369 httpSession->send(response.c_str(),
370 response.size());
371 }
372
373 const auto& wsConnectedCallback = httpSession->getWSConnectedCallback();
374 if (wsConnectedCallback != nullptr)
375 {
376 wsConnectedCallback(httpSession, *httpParser);
377 }
378 }
379
380 return retlen;
381 }
382};
383
384}}}// namespace brynet::net::http

Callers

nothing calls this directly

Calls 7

isCompletedMethod · 0.80
tryParseMethod · 0.80
isWebSocketMethod · 0.80
hasKeyMethod · 0.80
c_strMethod · 0.80
sendMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected