HTTP server data types. More...

Data Structures

struct gos_hs_param_t
HTTP GET/POST request parameter. More...
struct gos_hs_header_t
HTTP request header. More...
struct gos_hs_dynamic_page_t
Dynamic URL callback context. More...
struct gos_hs_tls_client_t
Information about connected TLS clients. More...
struct gos_hs_reply_config_t
HTTP response configuration. More...

Typedefs

typedef void * gos_hs_request_t
Internal HTTP server request context.
typedef gos_result_t (* gos_hs_request_processor_t ) (const gos_hs_request_t *request, const char *arg)
Dynamic URL callback prototype. More...
typedef bool(* gos_hs_custom_header_callback_t ) (const char *key, const char *value)
Custom header processing callback prototype. More...
typedef bool(* gos_hs_authorize_callback_t ) (const char *username, const char *password)
Authorize client credentials callback prototype. More...
typedef void(* gos_hs_not_found_callback_t ) (const gos_hs_request_t *request)
Requested URL not found callback prototype. More...
typedef void(* gos_hs_keepalive_callback_t ) (const gos_hs_request_t *request)
typedef void(* gos_hs_event_processing_callback_t ) ( gos_hs_request_t *request)
typedef gos_result_t (* gos_hs_direct_receive_callback_t ) (const gos_hs_request_t *request)

Enumerations

enum gos_hs_method_t {
GOS_HTTP_METHOD_GET = 0,
GOS_HTTP_METHOD_POST = 1,
GOS_HTTP_METHOD_HEAD = 2,
GOS_HTTP_METHOD_DELETE = 3,
GOS_HTTP_METHOD_OPTIONS = 4,
GOS_HTTP_METHOD_PUT = 5
}
HTTP request methods. More...
enum gos_hs_request_header_t {
GOS_HTTP_REQUEST_USER_AGENT ,
GOS_HTTP_REQUEST_TRANSFER_ENCODING ,
GOS_HTTP_REQUEST_CONTENT_TYPE ,
GOS_HTTP_REQUEST_AUTHORIZATION ,
GOS_HTTP_REQUEST_WS_KEY ,
GOS_HTTP_REQUEST_CONTENT_LENGTH ,
GOS_HTTP_REQUEST_CONNECTION ,
GOS_HTTP_REQUEST_ORIGIN
}
Default HTTP request header. More...
enum gos_hs_response_flag_t {
GOS_HS_RESPONSE_FLAG_NONE = 0,
GOS_HS_RESPONSE_FLAG_GZIP = (1 << 0),
GOS_HS_RESPONSE_FLAG_CACHE = (1 << 1),
GOS_HS_RESPONSE_FLAG_KEEPALIVE = (1 << 2)
}
Additional HTTP response header flags used by gos_hs_write_reply_header() More...

Detailed Description

HTTP server data types.

Typedef Documentation

gos_hs_authorize_callback_t

typedef bool(* gos_hs_authorize_callback_t) (const char *username, const char *password)

Authorize client credentials callback prototype.

If the HTTP request contain a 'Basic Authorization' header, this callback is called with the given username/password. This callback allows for denying unauthorized users.

Note
The callback executes in the HTTP server thread context
Parameters
[out] username Supplied username
[out] password Supplied password
Returns
true if user is authorized, false else

gos_hs_custom_header_callback_t

typedef bool(* gos_hs_custom_header_callback_t) (const char *key, const char *value)

Custom header processing callback prototype.

This callback is called when the HTTP request is being parsed. It called for each custom HTTP request header encountered.

Note
The callback executes in the HTTP server thread context
Parameters
[out] key The header key
[out] value The header value
Returns
true if header should be stored with request context, false else

gos_hs_direct_receive_callback_t

typedef gos_result_t (* gos_hs_direct_receive_callback_t) (const gos_hs_request_t *request)
Parameters
request

gos_hs_event_processing_callback_t

typedef void(* gos_hs_event_processing_callback_t) ( gos_hs_request_t *request)
Parameters
request

gos_hs_keepalive_callback_t

typedef void(* gos_hs_keepalive_callback_t) (const gos_hs_request_t *request)
Parameters
request

gos_hs_not_found_callback_t

typedef void(* gos_hs_not_found_callback_t) (const gos_hs_request_t *request)

Requested URL not found callback prototype.

This callback is called when the request URL route is not found.

Note
The callback executes in the HTTP server thread context
Parameters
[out] request Internal request context

gos_hs_request_processor_t

typedef gos_result_t (* gos_hs_request_processor_t) (const gos_hs_request_t *request, const char *arg)

Dynamic URL callback prototype.

Note
The callback executes in the HTTP server thread context
Parameters
[out] request Pointer to internal request context
[out] arg URL arguments (if callback was specified with 's' in URL)
Returns
gos_result_t result of processing request

Enumeration Type Documentation

gos_hs_method_t

HTTP request methods.

Enumerator
GOS_HTTP_METHOD_GET

GOS_HTTP_METHOD_GET.

GOS_HTTP_METHOD_POST

GOS_HTTP_METHOD_POST.

GOS_HTTP_METHOD_HEAD

GOS_HTTP_METHOD_HEAD.

GOS_HTTP_METHOD_DELETE

GOS_HTTP_METHOD_DELETE.

GOS_HTTP_METHOD_OPTIONS

GOS_HTTP_METHOD_OPTIONS.

GOS_HTTP_METHOD_PUT

GOS_HTTP_METHOD_PUT.

gos_hs_request_header_t

Default HTTP request header.

By default the HTTP server will only store the following HTTTP request headers. To store custom headers use gos_hs_register_header_callback()

Enumerator
GOS_HTTP_REQUEST_USER_AGENT

GOS_HTTP_REQUEST_USER_AGENT.

GOS_HTTP_REQUEST_TRANSFER_ENCODING

GOS_HTTP_REQUEST_TRANSFER_ENCODING.

GOS_HTTP_REQUEST_CONTENT_TYPE

GOS_HTTP_REQUEST_CONTENT_TYPE.

GOS_HTTP_REQUEST_AUTHORIZATION

GOS_HTTP_REQUEST_AUTHORIZATION.

GOS_HTTP_REQUEST_WS_KEY

GOS_HTTP_REQUEST_WS_KEY.

GOS_HTTP_REQUEST_CONTENT_LENGTH

GOS_HTTP_REQUEST_CONTENT_LENGTH.

GOS_HTTP_REQUEST_CONNECTION

GOS_HTTP_REQUEST_CONNECTION.

GOS_HTTP_REQUEST_ORIGIN

GOS_HTTP_REQUEST_ORIGIN.

gos_hs_response_flag_t

Additional HTTP response header flags used by gos_hs_write_reply_header()

Enumerator
GOS_HS_RESPONSE_FLAG_NONE

No additional response headers.

GOS_HS_RESPONSE_FLAG_GZIP

Returned data is gzip compressed.

GOS_HS_RESPONSE_FLAG_CACHE

Indicate that returned data/page should be cached (by default pages are NOT cached)

GOS_HS_RESPONSE_FLAG_KEEPALIVE

Indicate that the client should NOT close the connection after receiving the response.