Skip to content
Holger Jeromin edited this page Mar 13, 2015 · 2 revisions

Programmers guide for kshttp

This should be a documentation for reusing this code for example in https://github.com/acplt/open62541

The code uses the OV infrastructure for all string handling. This provides ov_string_print, ov_string_setvalue and ov_string_append which allocates the memory needed.

The main http handling is done in the file source/httpserver_httpgenerics.c. All typedefs and enums are in model/kshttp.ovt (for example the big structs KSHTTP_REQUEST, KSHTTP_RESPONSE). The function kshttp_httpclienthandler_HandleRequest() in source/httpclienthandler.c is called if new tcp traffic is received by the TCPbind library.

The request is first parsed by kshttp_httpclienthandler_analyzeRequestHeader which init the structs, read header (if full available) and parse it into a KSHTTP_REQUEST. Afterwards the kshttp_httpclienthandler_analyzeRequestBody is called to extract the RequestBody into heap memory. The file httpserver_httpgenerics.c should be independent of the OV object management system if compiled with a define HTTPSERVER_STANDALONE.

The next functions kshttp_httpclienthandler_generateHttpBody and kshttp_httpclienthandler_generateHttpHeader are OV specific for the KS Services of this http server.

kshttp_httpclienthandler_sendHttpHeader and ...Body are responsible for sending the header and body.

Clone this wiki locally