在libwebsockets客户端中建立连接时如何添加自定义标头字段?建立连接时(在调用lws_service()之前),我调用lws_add_http_header_by_name()。它不会将客户标头字段发送到服务器。似乎不正确。该功能仅适用于服务器端吗?还是我错过了什么?
unsigned char buffer[4096];
unsigned char *p = buffer + LWS_SEND_BUFFER_PRE_PADDING;
unsigned char *end = p + sizeof(buffer) - LWS_SEND_BUFFER_PRE_PADDING;
lws_add_http_header_by_name(client_wsi, reinterpret_cast<const unsigned char*>("CUSTOMER_HEADER"), reinterpret_cast<const unsigned char*>("CUSTOMER_HEADER_VALUE"), sizeof("CUSTOMER_HEADER_VALUE") -1, &p, end);
while (n >= 0) {
n = lws_service(context, 1000);
}