Skip to content

Files

Latest commit

88ef101 · May 22, 2025

History

History
28 lines (23 loc) · 903 Bytes

url_encode_params.md

File metadata and controls

28 lines (23 loc) · 903 Bytes

UrlEncode Parameters

Cweb Studio also supports URL parameter encoding. To do so, call the method request->read_content to parse the body:

#include "CWebStudioOne.c"

CwebHttpResponse *main_sever(CwebHttpRequest *request){
    CwebHttpRequest_read_content(request, 20000);
    CwebDict *query_paramns = request->params;
    for(int i = 0; i < query_paramns->size; i++){
        CwebKeyVal *key_val = query_paramns->keys_vals[i];
        char *key = key_val->key;
        char *value = key_val->value;
        printf("%s : %s\n", key, value);
    }
    printf("-----------------------------------------------\n");
    return cweb_send_text("Url readed", 200);
}

int main(int argc, char *argv[]){
    CwebServer server = newCwebSever(5000, main_sever);
    CwebServer_start(&server);
    return 0;
}

This example shows how to read and parse URL encoded parameters from the request body.