解答:
LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER = 24,
/**< this callback happens
* when a client handshake is being compiled. user is NULL,
* in is a char **, it's pointing to a char * which holds the
* next location in the header buffer where you can add
* headers, and len is the remaining space in the header buffer,
* which is typically some hundreds of bytes. So, to add a canned
* cookie, your handler code might look similar to:
*
* char **p = (char **)in, *end = (*p) + len;
*
* if (lws_add_http_header_by_token(wsi, WSI_TOKEN_HTTP_COOKIE,
* (unsigned char)"a=b", 3, p, end))
* return -1;
*
* See LWS_CALLBACK_ADD_HEADERS for adding headers to server
* transactions.
*/
该文解释了LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER回调的作用,它允许在客户端WebSocket握手过程中添加自定义HTTP头部。用户可以利用提供的指针和剩余缓冲区空间来插入如Cookie这样的头部信息。失败则返回-1。此方法类似于LWS_CALLBACK_ADD_HEADERS,但用于服务器交易。
3704

被折叠的 条评论
为什么被折叠?



