MCO_RET mco_lews_get_query_param_str(const char *in_buffer, mco_uint2 in_buf_size,
const char *param_name, char *out_buf, mco_uint2 out_buf_size);
in_buffer
in_buf_size
in_buffer.param_name
"format").out_buf
out_buf_size
out_buf buffer, including space for the null terminator.This function searches for a query or form parameter named
param_namein the provided buffer and copies its raw value as a null-terminated string intoout_buf.For HTTP GET requests, parameters are expected in the query string (the part after
?in the URL).
For HTTP POST requests withapplication/x-www-form-urlencodedcontent type, parameters are expected in the request body.The function does not perform URL decoding. The value is copied exactly as it appears in the input buffer (e.g.,
%20remains%20, and+remains+).lews_connection_context_h p_ctx; ... if (IS_METHOD(p_ctx, "GET")) { if (IS_URL(p_ctx, "/test")) { ret = mco_lews_get_query_param_str(p_ctx->incoming_buf + p_ctx->params_pos, p_ctx->params_len, "format", tmp_buf, sizeof(tmp_buf)); if (ret == MCO_S_OK) { /* Use 'tmp_buf' containing the raw (undecoded) value */ ... } } }
MCO_S_OK
out_buf as a null-terminated string.MCO_E_LEWS_NONEXISTENT_PARAMETER
MCO_E_LEWS_NO_ENOUGH_MEMORY
out_buf is too small to hold the parameter value (including the null terminator).