Embedded TCP/IP stack  4.7.0
HTTP server API

Detailed Description

The current version of the FNET HTTP Server supports:


After the FNET HTTP server is initialized by calling the fnet_http_srv_init() function, the user application should call the main service polling function fnet_service_poll() periodically in background.

For HTTP server usage example, refer to FNET demo application source code.

Configuration parameters:

Data Structures

struct  fnet_http_srv_tls_params_t
 HTTP over TLS (HTTPS) input parameters for fnet_http_srv_init(). More...
 
struct  fnet_http_srv_params_t
 Input parameters for fnet_http_srv_init(). More...
 
struct  fnet_http_srv_auth_t
 HTTP Authentication table. More...
 
struct  fnet_http_srv_cgi_t
 CGI callback function table. More...
 
struct  fnet_http_srv_post_t
 POST-method callback function table. More...
 
struct  fnet_http_srv_ssi_t
 SSI callback function table. More...
 

Macros

#define FNET_HTTP_SRV_VERSION_MAJOR
 The major version number of HTTP protocol supported by the HTTP server. More...
 
#define FNET_HTTP_SRV_VERSION_MINOR
 The minor version number of HTTP protocol supported by the HTTP server. More...
 
#define FNET_HTTP_SRV_CGI_EXTENSION   "cgi"
 CGI file extension.
All HTTP requests to the files that have this extension will be handled by the CGI handler.

. More...

 
#define FNET_HTTP_SRV_SSI_EXTENSION   "shtml"
 SSI file extension.
All files that have this extension will be parsed by the SSI parser.

. More...

 

Typedefs

typedef fnet_int32_t fnet_http_srv_desc_t
 HTTP server descriptor. More...
 
typedef fnet_int32_t fnet_http_srv_session_t
 HTTP session handle. More...
 
typedef fnet_return_t(* fnet_http_srv_cgi_handle_t) (fnet_http_srv_session_t session, fnet_char_t *query, fnet_uint32_t *cookie)
 Callback function prototype of the CGI query handler. More...
 
typedef fnet_size_t(* fnet_http_srv_cgi_send_t) (fnet_uint8_t *buffer, fnet_size_t buffer_size, fnet_bool_t *eof, fnet_uint32_t *cookie)
 Callback function prototype of the CGI response function. More...
 
typedef fnet_return_t(* fnet_http_srv_post_handle_t) (fnet_http_srv_session_t session, fnet_char_t *query, fnet_uint32_t *cookie)
 Callback function prototype of the POST-method query handler. More...
 
typedef fnet_return_t(* fnet_http_srv_post_receive_t) (fnet_http_srv_session_t session, fnet_uint8_t *buffer, fnet_size_t buffer_size, fnet_uint32_t *cookie)
 Callback function prototype of the POST-method receive function. More...
 
typedef fnet_size_t(* fnet_http_srv_post_send_t) (fnet_uint8_t *buffer, fnet_size_t buffer_size, fnet_bool_t *eof, fnet_uint32_t *cookie)
 Callback function prototype of the POST-method response function. More...
 
typedef fnet_return_t(* fnet_http_srv_ssi_handle_t) (fnet_char_t *query, fnet_uint32_t *cookie)
 Callback function prototype of the SSI parameters handler. More...
 
typedef fnet_size_t(* fnet_http_srv_ssi_send_t) (fnet_uint8_t *buffer, fnet_size_t buffer_size, fnet_bool_t *eof, fnet_uint32_t *cookie)
 Callback function prototype of the SSI include function. More...
 

Enumerations

enum  fnet_http_srv_status_code_t {
  FNET_HTTP_SRV_STATUS_CODE_NONE,
  FNET_HTTP_SRV_STATUS_CODE_OK,
  FNET_HTTP_SRV_STATUS_CODE_CREATED,
  FNET_HTTP_SRV_STATUS_CODE_ACCEPTED,
  FNET_HTTP_SRV_STATUS_CODE_NO_CONTENT,
  FNET_HTTP_SRV_STATUS_CODE_MOVED_PERMANENTLY,
  FNET_HTTP_SRV_STATUS_CODE_MOVED_TEMPORARILY,
  FNET_HTTP_SRV_STATUS_CODE_NOT_MODIFIED,
  FNET_HTTP_SRV_STATUS_CODE_BAD_REQUEST,
  FNET_HTTP_SRV_STATUS_CODE_UNAUTHORIZED,
  FNET_HTTP_SRV_STATUS_CODE_FORBIDDEN,
  FNET_HTTP_SRV_STATUS_CODE_NOT_FOUND,
  FNET_HTTP_SRV_STATUS_CODE_INTERNAL_SERVER_ERROR,
  FNET_HTTP_SRV_STATUS_CODE_NOT_IMPLEMENTED,
  FNET_HTTP_SRV_STATUS_CODE_BAD_GATEWAY,
  FNET_HTTP_SRV_STATUS_CODE_SERVICE_UNAVAILABLE
}
 HTTP/1.0 Status-Code definitions according to RFC1945. More...
 
enum  fnet_http_srv_auth_scheme_t {
  FNET_HTTP_SRV_AUTH_SCHEME_NONE,
  FNET_HTTP_SRV_AUTH_SCHEME_BASIC,
  FNET_HTTP_SRV_AUTH_SCHEME_DIGEST
}
 Type of Authentication Scheme. More...
 

Functions

fnet_http_srv_desc_t fnet_http_srv_init (fnet_http_srv_params_t *params)
 Initializes the HTTP Server service. More...
 
void fnet_http_srv_release (fnet_http_srv_desc_t desc)
 Releases the HTTP Server service. More...
 
fnet_bool_t fnet_http_srv_is_enabled (fnet_http_srv_desc_t desc)
 Detects if the HTTP Server service is enabled or disabled. More...
 
void fnet_http_srv_query_unencode (fnet_uint8_t *dest, fnet_uint8_t *src)
 Converts escaped string to an original format. More...
 
void fnet_http_srv_set_response_status_code (fnet_http_srv_session_t session, fnet_http_srv_status_code_t status_code)
 Sets status code in HTTP response status-line. More...
 
void fnet_http_srv_set_response_content_length (fnet_http_srv_session_t session, fnet_size_t content_length)
 Sets content length in HTTP response header. More...
 
void fnet_http_srv_set_response_no_header (fnet_http_srv_session_t session)
 Disables sending of HTTP response status-code and header. More...
 

© 2005-2020 by Andrej Butok. http://fnet.sourceforge.net