# mco_lews_is_websocket_request
RT

### Prototype

        mco_bool mco_lews_is_websocket_request(lews_connection_context_h ctx);

### Arguments

`ctx`
Handle to the connection context containing the parsed HTTP request.

### Description

> This function checks whether the current request is a WebSocket upgrade request (i.e., it contains the required headers such as `Upgrade: websocket` and `Connection: Upgrade`).

> It is typically used during request routing to determine if a WebSocket handshake should be performed instead of processing a regular HTTP response.

> Note: a return value of `0` only indicates the absence of WebSocket upgrade headers—it does not imply the request is valid HTTP.

>         ...
>         if (IS_URL(p_ctx, "/ws")) {
>             if (mco_lews_is_websocket_request(p_ctx)) {
>                 if (MCO_S_OK != mco_lews_websocket_negotiation_response(p_ctx)) {
>                     printf("mco_lews_websocket_negotiation_response error %d", ret);
>                     return;
>                 }
>                 // send data
>                 ...
>             }
>         }

### Return Value

`1`
The current request is a valid WebSocket upgrade request.
`0`
The request is not a WebSocket upgrade request.

### Files

Header file:
mcoewslite.h
Source file:
mcoewslite.c
Library:
mcoewslite.a