Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 836 Bytes

reading_body_content.md

File metadata and controls

33 lines (22 loc) · 836 Bytes

Reading Body Content

Accessing the body content may be done by calling the function request->read_content. The content will be accessible with request->content and request->content_length:

#include "CWebStudioOne.c"

CwebNamespace cweb;

CwebHttpResponse *main_sever(CwebHttpRequest *request ){
    int one_mega_byte = 1048576;

    unsigned char *body =  cweb.request.read_content(request, one_mega_byte);

    if(body){
        printf("body: %s",(char*)body);
         return cweb_send_text("Body Readed", 200);

    }
    return cweb_send_text("Body Not 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 the body content of the request.