Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 687 Bytes

getting_headers.md

File metadata and controls

31 lines (23 loc) · 687 Bytes

Getting Headers

For retrieving headers, use the cweb.request.get_header function.

#include "CWebStudioOne.c"

CwebNamespace cweb;

CwebHttpResponse *main_sever(CwebHttpRequest *request ){

    char *name = cweb.request.get_header(request,"name");
    if(name){
        printf("%s\n",name);
    }
    else{
        printf("name not provided\n");
    }
    return cweb.response.send_text("Hello World", 200);

}

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

This example demonstrates how to retrieve a header named 'name' from the request.