IS_METHOD

Prototype

    #define IS_METHOD(ctx, method) \
        mco_lews_strcmp(method, (ctx)->incoming_buf, (ctx)->method_pos, (ctx)->method_pos + (ctx)->method_len)

Arguments

ctx
Pointer to the connection context (lews_connection_context_h).
method
Null-terminated string containing the expected HTTP method (e.g., "GET", "POST").

Description

This macro checks whether the HTTP request method matches the specified method string.

It uses mco_lews_strcmp() by passing the start position of the method (method_pos) and a synthetic buffer size equal to method_pos + method_len. This effectively limits the comparison to the exact length of the parsed method token.

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")) {
            ...
        }
    }

Return Value

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

Files

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