Functions
http_upgrade.h File Reference

Protocol upgrade helper. More...

Functions

VTM_API bool vtm_http_is_ws_request (struct vtm_http_req *req)
 
VTM_API void vtm_http_get_ws_protocols (struct vtm_http_req *req, char ***protos, size_t *proto_count)
 
VTM_API int vtm_http_upgrade_to_ws (struct vtm_http_req *req, vtm_http_res *res, char *proto)
 

Function Documentation

VTM_API bool vtm_http_is_ws_request ( struct vtm_http_req req)

Checks if the given request is a WebSocket handshake request.

Parameters
reqthe request that should be checked
Returns
true if request is a WebSocket handshake request
false if not a handshake request
VTM_API void vtm_http_get_ws_protocols ( struct vtm_http_req req,
char ***  protos,
size_t *  proto_count 
)

Extracts the requested WebSocket protocols from the request.

Parameters
reqthe request where the protocols should be extracted from
[out]protoswill be filled with array of pointers to protocol names
[out]proto_countwill be filled with the number of protocol names
VTM_API int vtm_http_upgrade_to_ws ( struct vtm_http_req req,
vtm_http_res *  res,
char *  proto 
)

Prepares the response so that the connection is upgraded to WebSocket protocol afterwards.

Parameters
reqthe WebSocket handshake request
resthe response that should be filled
protothe chosen WebSocket protocol, can be NULL
Returns
VTM_OK if the response was successfully prepared
VTM_ERROR if an error occured