IS_URL

Prototype

    #define IS_URL(ctx, url) \
        mco_lews_strcmp(url, (ctx)->incoming_buf, (ctx)->url_pos, (ctx)->url_pos + (ctx)->url_len)

Arguments

ctx
Pointer to the connection context (lews_connection_context_h) containing the parsed HTTP request.
url
Null-terminated string representing the expected URL path (e.g., "/test").

Description

This macro checks whether the URL path in the current HTTP request exactly matches the specified url string.

It uses mco_lews_strcmp(), passing the start position of the URL (url_pos) and a synthetic buffer size of url_pos + url_len. This effectively restricts the comparison to the exact length of the parsed URL token, ensuring that only the path (without query parameters or fragments) is compared.

The comparison is case-sensitive and requires an exact match in both content and length.

    lews_connection_context_h p_ctx;
    ...
    if (IS_METHOD(p_ctx, "GET")) {
        if (IS_URL(p_ctx, "/test")) {
            // Handle request to /test
            ...
        }
    }

Return Value

1
The request URL path exactly matches the specified url string.
0
No match: strings differ, lengths are unequal, or input pointers are invalid.

Files

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