Skip to content

Latest commit

 

History

History
31 lines (25 loc) · 963 Bytes

url_encode_params.md

File metadata and controls

31 lines (25 loc) · 963 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"
CwebNamespace cweb;

CwebHttpResponse *main_sever(CwebHttpRequest *request ){
    cweb.request.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.response.send_text("Url readed", 200);

}

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

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