[Libwebsockets] How to reject the WS request with a 403 status

Chropin Hu chropinhu at gmail.com
Wed Jul 25 04:14:34 CEST 2018


I have tried anther API.
call the  lws_return_http_status at  *LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION
msg handler.*
The browser can receive the 403 code, it`s seems ok!

On Tue, Jul 24, 2018 at 5:07 PM, Chropin Hu <chropinhu at gmail.com> wrote:

> Dear All,
>       I am researching a way to varify the |origin| filed at the websocket
> handshake stage. (none TLS case)
>       if the orgin is invalid, the server will return  403 forbidden
> status code.
>       I have try to handle the *LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION*
> msg like this,
>               unsigned char buf[LWS_PRE + 384], *start = buf + LWS_PRE -
> 1, *p = start,
>      *end = buf + sizeof(buf) - 1;
>       lws_add_http_header_status(wsi, HTTP_STATUS_FORBIDDEN, &p, end);
>      But it can not work well.
>      Someone can help me out?
>
> Best Regards
>
> Yours Chropin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20180725/f23f3079/attachment-0002.html>


More information about the Libwebsockets mailing list