lwIP  2.0.2
Lightweight IP stack
HTTP server




void httpd_init (void)

Detailed Description

This httpd supports for a rudimentary server-side-include facility which will replace tags of the form in any file whose extension is .shtml, .shtm or .ssi with strings provided by an include handler whose pointer is provided to the module via function http_set_ssi_handler(). Additionally, a simple common gateway interface (CGI) handling mechanism has been added to allow clients to hook functions to particular request URIs.

To enable SSI support, define label LWIP_HTTPD_SSI in lwipopts.h. To enable CGI support, define label LWIP_HTTPD_CGI in lwipopts.h.

By default, the server assumes that HTTP headers are already present in each file stored in the file system. By defining LWIP_HTTPD_DYNAMIC_HEADERS in lwipopts.h, this behavior can be changed such that the server inserts the headers automatically based on the extension of the file being served. If this mode is used, be careful to ensure that the file system image used does not already contain the header information.

File system images without headers can be created using the makefsfile tool with the -h command line option.

Notes about valid SSI tags

The following assumptions are made about tags used in SSI markers:

  1. No tag may contain '-' or whitespace characters within the tag name.
  2. Whitespace is allowed between the tag leadin "<!--#" and the start of the tag name and between the tag name and the leadout string "-->".
  3. The maximum tag name length is LWIP_HTTPD_MAX_TAG_NAME_LEN, currently 8 characters.

Notes on CGI usage

The simple CGI support offered here works with GET method requests only and can handle up to 16 parameters encoded into the URI. The handler function may not write directly to the HTTP output but must return a filename that the HTTP server will send to the browser as a response to the incoming CGI request.

The list of supported file types is quite short, so if makefsdata complains about an unknown extension, make sure to add it (and its doctype) to the 'g_psHTTPHeaders' list.

Function Documentation

◆ httpd_init()

void httpd_init ( void  )

Initialize the httpd: set up a listening PCB and bind it to the defined port