mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-09 03:22:45 +03:00
Renamed mg_ functions to httplib_
This commit is contained in:
@@ -16,61 +16,61 @@ the API can be found in [Embedding.md](Embedding.md).
|
||||
## Structures
|
||||
|
||||
* [`struct client_cert;`](api/client_cert.md)
|
||||
* [`struct mg_client_options;`](api/mg_client_options.md)
|
||||
* [`struct mg_callbacks;`](api/mg_callbacks.md)
|
||||
* [`struct mg_form_data_handler;`](api/mg_form_data_handler.md)
|
||||
* [`struct mg_header;`](api/mg_header.md)
|
||||
* [`struct mg_option;`](api/mg_option.md)
|
||||
* [`struct mg_request_info;`](api/mg_request_info.md)
|
||||
* [`struct mg_server_ports;`](api/mg_server_ports.md)
|
||||
* [`struct httplib_client_options;`](api/httplib_client_options.md)
|
||||
* [`struct httplib_callbacks;`](api/httplib_callbacks.md)
|
||||
* [`struct httplib_form_data_handler;`](api/httplib_form_data_handler.md)
|
||||
* [`struct httplib_header;`](api/httplib_header.md)
|
||||
* [`struct httplib_option;`](api/httplib_option.md)
|
||||
* [`struct httplib_request_info;`](api/httplib_request_info.md)
|
||||
* [`struct httplib_server_ports;`](api/httplib_server_ports.md)
|
||||
|
||||
## Functions
|
||||
|
||||
* [`mg_check_feature( feature );`](api/mg_check_feature.md)
|
||||
* [`mg_close_connection( conn );`](api/mg_close_connection.md)
|
||||
* [`mg_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );`](api/mg_connect_client.md)
|
||||
* [`mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user_data);`](api/mg_connect_websocket_client.md)
|
||||
* [`mg_cry( conn, fmt, ... );`](api/mg_cry.md)
|
||||
* [`mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`](api/mg_download.md)
|
||||
* [`httplib_check_feature( feature );`](api/httplib_check_feature.md)
|
||||
* [`httplib_close_connection( conn );`](api/httplib_close_connection.md)
|
||||
* [`httplib_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );`](api/httplib_connect_client.md)
|
||||
* [`httplib_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user_data);`](api/httplib_connect_websocket_client.md)
|
||||
* [`httplib_cry( conn, fmt, ... );`](api/httplib_cry.md)
|
||||
* [`httplib_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`](api/httplib_download.md)
|
||||
* [`httplib_get_builtin_mime_type( file_name );`](api/httplib_get_builtin_mime_type.md)
|
||||
* [`mg_get_context( conn );`](api/mg_get_context.md)
|
||||
* [`mg_get_cookie( cookie, var_name, buf, buf_len );`](api/mg_get_cookie.md)
|
||||
* [`mg_get_header( conn, name );`](api/mg_get_header.md)
|
||||
* [`mg_get_option( ctx, name );`](api/mg_get_option.md)
|
||||
* [`mg_get_request_info( conn );`](api/mg_get_request_info.md)
|
||||
* [`mg_get_response( conn, ebuf, ebuf_len, timeout );`](api/mg_get_response.md)
|
||||
* [`mg_get_response_code_text( conn, response_code );`](api/mg_get_response_code_text.md)
|
||||
* [`mg_get_server_ports( ctx, size, ports );`](api/mg_get_server_ports.md)
|
||||
* [`mg_get_user_connection_data( conn );`](api/mg_get_user_connection_data.md)
|
||||
* [`mg_get_user_data( ctx );`](api/mg_get_user_data.md)
|
||||
* [`mg_get_valid_options();`](api/mg_get_valid_options.md)
|
||||
* [`mg_get_var( data, data_len, var_name, dst, dst_len );`](api/mg_get_var.md)
|
||||
* [`mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`](api/mg_get_var2.md)
|
||||
* [`mg_handle_form_request( conn, fdh );`](api/mg_handle_form_request.md)
|
||||
* [`mg_lock_connection( conn );`](api/mg_lock_connection.md)
|
||||
* [`mg_lock_context( ctx );`](api/mg_lock_context.md)
|
||||
* [`mg_md5( buf, ... );`](api/mg_md5.md)
|
||||
* [`mg_modify_passwords_file( passwords_file_name, domain, user, password );`](api/mg_modify_passwords_file.md)
|
||||
* [`mg_printf( conn, fmt, ... );`](api/mg_printf.md)
|
||||
* [`mg_read( conn, buf, len );`](api/mg_read.md)
|
||||
* [`mg_send_file( conn, path );`](api/mg_send_file.md)
|
||||
* [`mg_send_mime_file( conn, path, mime_type );`](api/mg_send_mime_file.md)
|
||||
* [`mg_send_mime_file2( conn, path, mime_type, additional_headers );`](api/mg_send_mime_file2.md)
|
||||
* [`mg_set_auth_handler( ctx, uri, handler, cbdata );`](api/mg_set_auth_handler.md)
|
||||
* [`mg_set_request_handler( ctx, uri, handler, cbdata );`](api/mg_set_request_handler.md)
|
||||
* [`mg_set_user_connection_data( conn, data );`](api/mg_set_user_connection_data.md)
|
||||
* [`mg_set_websocket_handler( ctx, uri, connect_handler, ready_handler, data_handler, close_handler, cbdata );`](api/mg_set_websocket_handler.md)
|
||||
* [`mg_start( callbacks, user_data, options );`](api/mg_start.md)
|
||||
* [`mg_start_thread( f, p );`](api/mg_start_thread.md)
|
||||
* [`mg_store_body( conn, path );`](api/mg_store_body.md)
|
||||
* [`mg_stop( ctx );`](api/mg_stop.md)
|
||||
* [`mg_strcasecmp( s1, s2 );`](api/mg_strcasecmp.md)
|
||||
* [`mg_strncasecmp( s1, s2, len );`](api/mg_strncasecmp.md)
|
||||
* [`mg_unlock_connection( conn );`](api/mg_unlock_connection.md)
|
||||
* [`mg_unlock_context( ctx );`](api/mg_unlock_context.md)
|
||||
* [`mg_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );`](api/mg_url_decode.md)
|
||||
* [`mg_url_encode( src, dst, dst_len );`](api/mg_url_encode.md)
|
||||
* [`mg_version();`](api/mg_version.md)
|
||||
* [`mg_websocket_client_write( conn, opcode, data, data_len );`](api/mg_websocket_client_write.md)
|
||||
* [`mg_websocket_write( conn, opcode, data, data_len );`](api/mg_websocket_write.md)
|
||||
* [`mg_write( conn, buf, len );`](api/mg_write.md)
|
||||
* [`httplib_get_context( conn );`](api/httplib_get_context.md)
|
||||
* [`httplib_get_cookie( cookie, var_name, buf, buf_len );`](api/httplib_get_cookie.md)
|
||||
* [`httplib_get_header( conn, name );`](api/httplib_get_header.md)
|
||||
* [`httplib_get_option( ctx, name );`](api/httplib_get_option.md)
|
||||
* [`httplib_get_request_info( conn );`](api/httplib_get_request_info.md)
|
||||
* [`httplib_get_response( conn, ebuf, ebuf_len, timeout );`](api/httplib_get_response.md)
|
||||
* [`httplib_get_response_code_text( conn, response_code );`](api/httplib_get_response_code_text.md)
|
||||
* [`httplib_get_server_ports( ctx, size, ports );`](api/httplib_get_server_ports.md)
|
||||
* [`httplib_get_user_connection_data( conn );`](api/httplib_get_user_connection_data.md)
|
||||
* [`httplib_get_user_data( ctx );`](api/httplib_get_user_data.md)
|
||||
* [`httplib_get_valid_options();`](api/httplib_get_valid_options.md)
|
||||
* [`httplib_get_var( data, data_len, var_name, dst, dst_len );`](api/httplib_get_var.md)
|
||||
* [`httplib_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`](api/httplib_get_var2.md)
|
||||
* [`httplib_handle_form_request( conn, fdh );`](api/httplib_handle_form_request.md)
|
||||
* [`httplib_lock_connection( conn );`](api/httplib_lock_connection.md)
|
||||
* [`httplib_lock_context( ctx );`](api/httplib_lock_context.md)
|
||||
* [`httplib_md5( buf, ... );`](api/httplib_md5.md)
|
||||
* [`httplib_modify_passwords_file( passwords_file_name, domain, user, password );`](api/httplib_modify_passwords_file.md)
|
||||
* [`httplib_printf( conn, fmt, ... );`](api/httplib_printf.md)
|
||||
* [`httplib_read( conn, buf, len );`](api/httplib_read.md)
|
||||
* [`httplib_send_file( conn, path );`](api/httplib_send_file.md)
|
||||
* [`httplib_send_mime_file( conn, path, mime_type );`](api/httplib_send_mime_file.md)
|
||||
* [`httplib_send_mime_file2( conn, path, mime_type, additional_headers );`](api/httplib_send_mime_file2.md)
|
||||
* [`httplib_set_auth_handler( ctx, uri, handler, cbdata );`](api/httplib_set_auth_handler.md)
|
||||
* [`httplib_set_request_handler( ctx, uri, handler, cbdata );`](api/httplib_set_request_handler.md)
|
||||
* [`httplib_set_user_connection_data( conn, data );`](api/httplib_set_user_connection_data.md)
|
||||
* [`httplib_set_websocket_handler( ctx, uri, connect_handler, ready_handler, data_handler, close_handler, cbdata );`](api/httplib_set_websocket_handler.md)
|
||||
* [`httplib_start( callbacks, user_data, options );`](api/httplib_start.md)
|
||||
* [`httplib_start_thread( f, p );`](api/httplib_start_thread.md)
|
||||
* [`httplib_store_body( conn, path );`](api/httplib_store_body.md)
|
||||
* [`httplib_stop( ctx );`](api/httplib_stop.md)
|
||||
* [`httplib_strcasecmp( s1, s2 );`](api/httplib_strcasecmp.md)
|
||||
* [`httplib_strncasecmp( s1, s2, len );`](api/httplib_strncasecmp.md)
|
||||
* [`httplib_unlock_connection( conn );`](api/httplib_unlock_connection.md)
|
||||
* [`httplib_unlock_context( ctx );`](api/httplib_unlock_context.md)
|
||||
* [`httplib_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );`](api/httplib_url_decode.md)
|
||||
* [`httplib_url_encode( src, dst, dst_len );`](api/httplib_url_encode.md)
|
||||
* [`httplib_version();`](api/httplib_version.md)
|
||||
* [`httplib_websocket_client_write( conn, opcode, data, data_len );`](api/httplib_websocket_client_write.md)
|
||||
* [`httplib_websocket_write( conn, opcode, data, data_len );`](api/httplib_websocket_write.md)
|
||||
* [`httplib_write( conn, buf, len );`](api/httplib_write.md)
|
||||
|
@@ -13,9 +13,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The structure `client_cert` is used as a sub-structure in the [`mg_request_info`](mg_request_info.md) structure to store information of an optional client supplied certificate.
|
||||
The structure `client_cert` is used as a sub-structure in the [`httplib_request_info`](httplib_request_info.md) structure to store information of an optional client supplied certificate.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_request_info;`](mg_request_info.md)
|
||||
* [`mg_get_request_info();`](mg_get_request_info.md)
|
||||
* [`struct httplib_request_info;`](httplib_request_info.md)
|
||||
* [`httplib_get_request_info();`](httplib_get_request_info.md)
|
||||
|
@@ -24,5 +24,5 @@ The function uses an efficient binary search algorithm, but this has implication
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_send_mime_file();`](mg_send_mime_file.md)
|
||||
* [`mg_send_mime_file2();`](mg_send_mime_file2.md)
|
||||
* [`httplib_send_mime_file();`](httplib_send_mime_file.md)
|
||||
* [`httplib_send_mime_file2();`](httplib_send_mime_file2.md)
|
||||
|
26
doc/api/httplib_read.md
Normal file
26
doc/api/httplib_read.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_read( conn, buf, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct httplib_connection *`| A pointer referencing the connection |
|
||||
|**`buf`**|`void *`| A pointer to the location where the received data can be stored |
|
||||
|**`len`**|`size_t`| The maximum number of bytes to be stored in the buffer |
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`| The number of read bytes, or a status indication |
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_read()` receives data over an existing connection. The data is handled as binary and is stored in a buffer whose address has been provided as a parameter. The function returns the number of read bytes when successful, the value **0** when the connection has been closed by peer and a negative value when no more data could be read from the connection.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
25
doc/api/httplib_send_file.md
Normal file
25
doc/api/httplib_send_file.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_send_file( conn, path );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct httplib_connection *`|The connection over which the file must be sent|
|
||||
|**`path`**|`const char *`|The full path and filename of the file|
|
||||
|
||||
### Return Value
|
||||
|
||||
*none*
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_send_file()` sends the contents of a file over a connection to the remote peer. The function also adds the necessary HTTP headers.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_send_mime_file();`](httplib_send_mime_file.md)
|
||||
* [`httplib_send_mime_file2();`](httplib_send_mime_file2.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
29
doc/api/httplib_write.md
Normal file
29
doc/api/httplib_write.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `httplib_write( conn, buf, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct httplib_connection *`| A pointer to the connection to be used to send data |
|
||||
|**`buf`**|`const void *`| A pointer to the blob of information to be sent |
|
||||
|**`len`**|`size_t`| The amount of bytes to be sent |
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`| An integer indicating the amount of bytes sent, or failure |
|
||||
|
||||
### Description
|
||||
|
||||
The function `httplib_write()` can be used to send a blob of arbitrary data over a connection. The size of the data is provided as a parameter. The only length limitation on this function is `MAX_INT`, because the return value of this function will turn negative with larger blocks of data, although they may have been sent correctly. The function returns the amount of bytes sent in case of success, the value **0** when the connection has been closed, and **-1** in case of an error.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_printf();`](httplib_print.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
* [`httplib_websocket_client_write();`](httplib_websocket_client_write.md)
|
||||
* [`httplib_websocket_write();`](httplib_websocket_write.md)
|
@@ -1,46 +1,46 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_callbacks;`
|
||||
### `struct httplib_callbacks;`
|
||||
|
||||
### Fields
|
||||
|
||||
| Field | Description |
|
||||
| :--- | :--- |
|
||||
|**`begin_request`**|**`int (*begin_request)( struct mg_connection * conn );`**|
|
||||
|**`begin_request`**|**`int (*begin_request)( struct httplib_connection * conn );`**|
|
||||
| |The `begin_request()` callback function is called when LibHTTP has received a new HTTP request. If the callback function does not process the request, it should return 0. In that case LibHTTP will handle the request with the default callback routine. If the callback function returns a value between 1 and 999, LibHTTP does nothing and the callback function should do all the processing, including sending the proper HTTP headers etc. Starting at LibHTTP version 1.7, the function `begin_request()` is called before any authorization is done. If an authorization check is required, `request_handler()` should be used instead. The return value of the callback function is not only used to signal LibHTTP to not further process the request. The returned value is also stored as HTTP status code in the access log. |
|
||||
|**`connection_close`**|**`void (*connection_close)( const struct mg_connection *conn );`**|
|
||||
| |The callback function `connection_close()` is called when LibHTTP is closing a connection. The per-context mutex is locked when the callback function is invoked. The function is primarly useful for noting when a websocket is closing and removing it from any application-maintained list of clients. *Using this callback for websocket connections is deprecated. Use* `mg_set_websocket_handler()` *instead.*|
|
||||
|**`end_request`**|**`void (*end_request)( const struct mg_connection * conn );`**|
|
||||
|**`connection_close`**|**`void (*connection_close)( const struct httplib_connection *conn );`**|
|
||||
| |The callback function `connection_close()` is called when LibHTTP is closing a connection. The per-context mutex is locked when the callback function is invoked. The function is primarly useful for noting when a websocket is closing and removing it from any application-maintained list of clients. *Using this callback for websocket connections is deprecated. Use* `httplib_set_websocket_handler()` *instead.*|
|
||||
|**`end_request`**|**`void (*end_request)( const struct httplib_connection * conn );`**|
|
||||
| |The callback function `end_request()` is called by LibHTTP when a request has been completely processed. It sends the reply status code which was sent to the client to the application.|
|
||||
|**`exit_context`**|**`void (*exit_context)( const struct mg_context *ctx );`**|
|
||||
|**`exit_context`**|**`void (*exit_context)( const struct httplib_context *ctx );`**|
|
||||
| |The callback function `exit_context()` is called by LibHTTP when the server is stopped. It allows the application to do some cleanup on the application side.|
|
||||
|**`http_error`**|**`int (*http_error)( struct mg_connection *conn, int status );`**|
|
||||
|**`http_error`**|**`int (*http_error)( struct httplib_connection *conn, int status );`**|
|
||||
| |The callback function `http_error()` is called by LibHTTP just before an HTTP error is to be sent to the client. The function allows the application to send a custom error page. The status code of the error is provided as a parameter. If the application sends their own error page, it must return 1 to signal LibHTTP that no further processing is needed. If the returned value is 0, LibHTTP will send a built-in error page to the client.|
|
||||
|**`init_context`**|**`void (*init_context)( const struct mg_context *ctx );`**|
|
||||
|**`init_context`**|**`void (*init_context)( const struct httplib_context *ctx );`**|
|
||||
| |The callback function `init_context()` is called after the LibHTTP server has been started and initialized, but before any requests are served. This allowes the application to perform some initialization activities before the first requests are handled.|
|
||||
|**`init_lua`**|**`void (*init_lua)( const struct mg_connection *conn, void *lua_context );`**|
|
||||
|**`init_lua`**|**`void (*init_lua)( const struct httplib_connection *conn, void *lua_context );`**|
|
||||
| |The callback function `init_lua()` is called just before a Lua server page is to be served. Lua page serving must have been enabled at compile time for this callback function to be called. The parameter `lua_context` is a `lua_State *` pointer.|
|
||||
|**`init_ssl`**|**`int (*init_ssl)( void *ssl_context, void *user_data );`**|
|
||||
| |The callback function `init_ssl()` is called when LibHTTP initializes the SSL library. The parameter `user_data` contains a pointer to the data which was provided to `mg_start()` when the server was started. The callback function can return 0 to signal that LibHTTP should setup the SSL certificate. With a return value of 1 the callback function signals LibHTTP that the certificate has already been setup and no further processing is necessary. The value -1 should be returned when the SSL initialization fails.|
|
||||
|**`init_thread`**|**`void (*init_thread)( const struct mg_context *ctx, int thread_type );`**|
|
||||
| |The callback function `init_ssl()` is called when LibHTTP initializes the SSL library. The parameter `user_data` contains a pointer to the data which was provided to `httplib_start()` when the server was started. The callback function can return 0 to signal that LibHTTP should setup the SSL certificate. With a return value of 1 the callback function signals LibHTTP that the certificate has already been setup and no further processing is necessary. The value -1 should be returned when the SSL initialization fails.|
|
||||
|**`init_thread`**|**`void (*init_thread)( const struct httplib_context *ctx, int thread_type );`**|
|
||||
| |The callback function `init_thread()` is called when a new thread is created by LibHTTP. The `thread_type` parameter indicates which type of thread has been created. following thread types are recognized:|
|
||||
| |**0** - The master thread is created |
|
||||
| |**1** - A worker thread which handles client connections has been created|
|
||||
| |**2** - An internal helper thread (timer thread) has been created|
|
||||
|**`log_access`**|**`int (*log_access)( const struct mg_connection *conn, const char *message );`**|
|
||||
|**`log_access`**|**`int (*log_access)( const struct httplib_connection *conn, const char *message );`**|
|
||||
| |The callback function `log_access()` is called when LibHTTP is about to log a message. If the callback function returns 0, LibHTTP will use the default internal access log routines to log the access. If a non-zero value is returned, LibHTTP assumes that access logging has already been done and no further action is performed.|
|
||||
|**`log_message`**|**`int (*log_message)( const struct mg_connection *conn, const char *message );`**|
|
||||
|**`log_message`**|**`int (*log_message)( const struct httplib_connection *conn, const char *message );`**|
|
||||
| |The callback function `log_message()` is called when LibHTTP is about to log a message. If the callback function returns 0, LibHTTP will use the default internal log routines to log the message. If a non-zero value is returned LibHTTP assumes that logging has already been done and no further action is performed.|
|
||||
|**`open_file`**|**`const char *(*open_file)( const struct mg_connection *conn, const char *path, size_t *data_len );`**|
|
||||
|**`open_file`**|**`const char *(*open_file)( const struct httplib_connection *conn, const char *path, size_t *data_len );`**|
|
||||
| |The callback function `open_file()` is called when a file is to be opened by LibHTTP. The callback can return a pointer to a memory location and set the memory block size in the variable pointed to by `data_len` to signal LibHTTP that the file should not be loaded from disk, but that instead a stored version in memory should be used. If the callback function returns NULL, LibHTTP will open the file from disk. This callback allows caching to be implementedi at the application side, or to serve specific files from static memory instead of from disk.|
|
||||
|
||||
### Description
|
||||
|
||||
Much of the functionality in the LibHTTP library is provided through callback functions. The application registers their own processing functions with the LibHTTP library and when an event happens, the appropriate callback function is called. In this way an application is able to have their processing code right at the heart of the webserver, without the need to change the code of the webserver itself. A number of callback functions are registered when the LibHTTP subsystem is started. Other may be added or changed at runtime with helper functions.
|
||||
|
||||
A pointer to a `mg_callbacks` structure is passed as parameter to the [`mg_start()`](mg_start.md) function to provide links to callback functions which the webserver will call at specific events. If a specific callback function is not supplied, LibHTTP will fallback to default internal callback routines. Callback functions give the application detailed control over how specific events should be handled.
|
||||
A pointer to a `httplib_callbacks` structure is passed as parameter to the [`httplib_start()`](httplib_start.md) function to provide links to callback functions which the webserver will call at specific events. If a specific callback function is not supplied, LibHTTP will fallback to default internal callback routines. Callback functions give the application detailed control over how specific events should be handled.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`mg_stop();`](mg_stop.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
* [`httplib_stop();`](httplib_stop.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_check_feature( feature );`
|
||||
### `httplib_check_feature( feature );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_check_feature()` can be called from an application program to check of specific features have been compiled in the LibHTTP version which the application has been linked to. The feature to check is provided as an unsigned integer parameter. If the function is available in the currently linked library version, a value **> 0** is returned. Otherwise the function `mg_check_feature()` returns the value **0**.
|
||||
The function `httplib_check_feature()` can be called from an application program to check of specific features have been compiled in the LibHTTP version which the application has been linked to. The feature to check is provided as an unsigned integer parameter. If the function is available in the currently linked library version, a value **> 0** is returned. Otherwise the function `httplib_check_feature()` returns the value **0**.
|
||||
|
||||
The following parameter values can be used:
|
||||
|
||||
@@ -29,9 +29,9 @@ The following parameter values can be used:
|
||||
| **16** | USE_WEBSOCKET | Support for web sockets. WebSockets support is available in the LibHTTP library if the proper options has been used during cimpile time. |
|
||||
| **128** | NO_CACHING | *Support for caching*. The webserver will support caching, if it has not been disabled while compiling the library. |
|
||||
|
||||
Parameter values other than the values mentioned above will give undefined results. Therefore—although the parameter values for the `mg_check_feature()` function are effectively bitmasks, you should't assume that combining two of those values with an OR to a new value will give any meaningful results when the function returns.
|
||||
Parameter values other than the values mentioned above will give undefined results. Therefore—although the parameter values for the `httplib_check_feature()` function are effectively bitmasks, you should't assume that combining two of those values with an OR to a new value will give any meaningful results when the function returns.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_option();`](mg_get_option.md)
|
||||
* [`mg_get_valid_options();`](mg_get_valid_options.md)
|
||||
* [`httplib_get_option();`](httplib_get_option.md)
|
||||
* [`httplib_get_valid_options();`](httplib_get_valid_options.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_client_options;`
|
||||
### `struct httplib_client_options;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The the `mgclient_options` structure contains host and security information to connect as a client to another host. A parameter of this type is used in the call to the function [`mg_connect_client_secure()`](mg_connect_client_secure.md). Please note that IPv6 addresses are only permitted if IPv6 support was enabled during compilation. You can use the function [`mg_check_feature()`](mg_check_feature.md) with the parameter `USE_IPV6` while running your application to check if IPv6 is supported.
|
||||
The the `mgclient_options` structure contains host and security information to connect as a client to another host. A parameter of this type is used in the call to the function [`httplib_connect_client_secure()`](httplib_connect_client_secure.md). Please note that IPv6 addresses are only permitted if IPv6 support was enabled during compilation. You can use the function [`httplib_check_feature()`](httplib_check_feature.md) with the parameter `USE_IPV6` while running your application to check if IPv6 is supported.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_connect_client_secure();`](mg_connect_client_secure.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_connect_client_secure();`](httplib_connect_client_secure.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_close_connection( conn );`
|
||||
### `httplib_close_connection( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection which must be closed|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection which must be closed|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_close_connection()` is used to close a connection which was opened with the [`mg_download()`](mg_download.md) function. Use of this function to close a connection which was opened in another way is undocumented and may give unexpected results.
|
||||
The function `httplib_close_connection()` is used to close a connection which was opened with the [`httplib_download()`](httplib_download.md) function. Use of this function to close a connection which was opened in another way is undocumented and may give unexpected results.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_download();`](mg_download.md)
|
||||
* [`httplib_download();`](httplib_download.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );`
|
||||
### `httplib_connect_client( host, port, use_ssl, error_buffer, error_buffer_size );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_connection *`|A pointer to the connection or NULL when an error occurs|
|
||||
|`struct httplib_connection *`|A pointer to the connection or NULL when an error occurs|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_connect_client()` connects to a TCP server as a client. This server can be a HTTP server but this is not necessary. The function returns a pointer to a connection structure when the connection is established and NULL otherwise. The host may be on IPv4 or IPv6, but IPv6 is not enabled in every LibHTTP installation. Specifically the use of IPv6 communications has to be enabled when the library is compiled. At runtime you can use the [`mg_check_feature()`](mg_check_feature.md) function with the parameter `USE_IPV6` to check if IPv6 communication is supported.
|
||||
The function `httplib_connect_client()` connects to a TCP server as a client. This server can be a HTTP server but this is not necessary. The function returns a pointer to a connection structure when the connection is established and NULL otherwise. The host may be on IPv4 or IPv6, but IPv6 is not enabled in every LibHTTP installation. Specifically the use of IPv6 communications has to be enabled when the library is compiled. At runtime you can use the [`httplib_check_feature()`](httplib_check_feature.md) function with the parameter `USE_IPV6` to check if IPv6 communication is supported.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_connect_client_secure();`](mg_connect_client_secure.md)
|
||||
* [`mg_connect_websocket_client();`](mg_connect_websocket_client.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_connect_client_secure();`](httplib_connect_client_secure.md)
|
||||
* [`httplib_connect_websocket_client();`](httplib_connect_websocket_client.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_connect_client_secure( client_options, error_buffer, error_buffer_size );`
|
||||
### `httplib_connect_client_secure( client_options, error_buffer, error_buffer_size );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`client_options`**|`const struct mg_client_options *`|Settings about the server connection|
|
||||
|**`client_options`**|`const struct httplib_client_options *`|Settings about the server connection|
|
||||
|**`error_buffer`**|`char *`|Buffer to store an error message|
|
||||
|**`error_buffer_size`**|`size_t`|Size of the error message buffer including the NUL terminator|
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_connection *`|Pointer to the connection information or NULL if an error occured|
|
||||
|`struct httplib_connection *`|Pointer to the connection information or NULL if an error occured|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_connect_client_secure()` creates a secure connection with a server. The information about the connection and server is passed in a structure and an error message may be returned in a local buffer. The function returns a pointer to a `struct mg_connection` structure when successful and NULL otherwise.
|
||||
The function `httplib_connect_client_secure()` creates a secure connection with a server. The information about the connection and server is passed in a structure and an error message may be returned in a local buffer. The function returns a pointer to a `struct httplib_connection` structure when successful and NULL otherwise.
|
||||
|
||||
Please note that IPv6 communication is supported by LibHTTP, but only if the use of IPv6 was enabled at compile time. The check while running a program if IPv6 communication is possible you can call [`mg_check_feature()`](mg_check_feature.md) with the `USE_IPV6` parameter to check if IPv6 communications can be used.
|
||||
Please note that IPv6 communication is supported by LibHTTP, but only if the use of IPv6 was enabled at compile time. The check while running a program if IPv6 communication is possible you can call [`httplib_check_feature()`](httplib_check_feature.md) with the `USE_IPV6` parameter to check if IPv6 communications can be used.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_client_options;`](mg_client_options.md)
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_connect_client();`](mg_connect_client.md)
|
||||
* [`mg_connect_websocket_client();`](mg_connect_websocket_client.md)
|
||||
* [`struct httplib_client_options;`](httplib_client_options.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_connect_client();`](httplib_connect_client.md)
|
||||
* [`httplib_connect_websocket_client();`](httplib_connect_websocket_client.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user-data);`
|
||||
### `httplib_connect_websocket_client( host, port, use_ssl, error_buffer, error_buffer_size, path, origin, data_func, close_func, user-data);`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -13,24 +13,24 @@
|
||||
|**`error_buffer_size`**|`size_t`|Size of the error message buffer including the NUL terminator|
|
||||
|**`path`**|`const char *`|The server path to connect to, for example `/app` if you want to connect to `localhost/app`|
|
||||
|**`origin`**|`const char *`|The value of the `Origin` HTTP header|
|
||||
|**`data_func`**|`mg_websocket_data_handler`|Callback which is used to process data coming back from the server|
|
||||
|**`close_func`**|`mg_websocket_close_handler`|Callback which is called when the connection is to be closed|
|
||||
|**`data_func`**|`httplib_websocket_data_handler`|Callback which is used to process data coming back from the server|
|
||||
|**`close_func`**|`httplib_websocket_close_handler`|Callback which is called when the connection is to be closed|
|
||||
|**`user_data`**|`void *`|User supplied argument|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_connection *`|A pointer to the connection structure, or NULL if connecting failed|
|
||||
|`struct httplib_connection *`|A pointer to the connection structure, or NULL if connecting failed|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_connect_websocket_client()` connects to a websocket on a server as a client. Data and close events are processed with callback functions which must be provided in the call.
|
||||
The function `httplib_connect_websocket_client()` connects to a websocket on a server as a client. Data and close events are processed with callback functions which must be provided in the call.
|
||||
|
||||
LibHTTP supports both IPv4 and IPv6 communication, but only if the use if IPv6 has been enabled at compile time. When running an application it is possible to check if IPv6 addressing is available by calling the [`mg_check_feature()`](mg_check_feature.md) function with the `USE_IPV6` parameter.
|
||||
LibHTTP supports both IPv4 and IPv6 communication, but only if the use if IPv6 has been enabled at compile time. When running an application it is possible to check if IPv6 addressing is available by calling the [`httplib_check_feature()`](httplib_check_feature.md) function with the `USE_IPV6` parameter.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_connect_client();`](mg_connect_client.md)
|
||||
* [`mg_connect_client_secure();`](mg_connect_client_secure.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_connect_client();`](httplib_connect_client.md)
|
||||
* [`httplib_connect_client_secure();`](httplib_connect_client_secure.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_cry( conn, fmt, ... );`
|
||||
### `httplib_cry( conn, fmt, ... );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`const struct mg_connection *`|The connection on which a problem occured|
|
||||
|**`conn`**|`const struct httplib_connection *`|The connection on which a problem occured|
|
||||
|**`fmt`**|`const char *`|Format string without a line return|
|
||||
|**`...`**|*various*|Parameters depending on the format string|
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_cry()` is called when something happens on a connection. The function takes a format string similar to the `printf()` series of functions with parameters and creates a text string which can then be used for logging. The `mg_cry()` function prints the output to the opened error log stream. Log messages can be processed with the `log_message()` callback function specified in the `struct mg_callbacks` structure.
|
||||
The function `httplib_cry()` is called when something happens on a connection. The function takes a format string similar to the `printf()` series of functions with parameters and creates a text string which can then be used for logging. The `httplib_cry()` function prints the output to the opened error log stream. Log messages can be processed with the `log_message()` callback function specified in the `struct httplib_callbacks` structure.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_callbacks;`](mg_callbacks.md)
|
||||
* [`struct httplib_callbacks;`](httplib_callbacks.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`
|
||||
### `httplib_download( host, port, use_ssl, error_buffer, error_buffer_size, fmt, ... );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_connection *`|A pointer to the connection structure if successful and NULL otherwise|
|
||||
|`struct httplib_connection *`|A pointer to the connection structure if successful and NULL otherwise|
|
||||
|
||||
### Description
|
||||
|
||||
The `mg_download()` function is used to download data from a remote webserver. The server address can either be specified as a hostname or IP address and SSL can be used if needed. If the function succeeds, a pointer is returned to a connection structure. The connection must be closed with a call to the [`mg_close_connection()`](mg_close_connection.md) function.
|
||||
The `httplib_download()` function is used to download data from a remote webserver. The server address can either be specified as a hostname or IP address and SSL can be used if needed. If the function succeeds, a pointer is returned to a connection structure. The connection must be closed with a call to the [`httplib_close_connection()`](httplib_close_connection.md) function.
|
||||
|
||||
The format string is a format string from the `printf()` series of functions to specify the remote command. An example to get the main index page from Google is the following call:
|
||||
|
||||
`conn = mg_download( "google.com", 80, 0, ebuf, sizeof(ebuf),
|
||||
`conn = httplib_download( "google.com", 80, 0, ebuf, sizeof(ebuf),
|
||||
"%s", "GET / HTTP/1.0\r\nHost: google.com\r\n\r\n" );`
|
||||
|
||||
Please note that although LibHTTP supports both IPv4 and IPv6 communication that IPv6 addressing is only available if it was enabled at compile time. When running an application it is possible to check if IPv6 support has been compiled in by using the [`mg_check_feature()`](mg_check_feature.md) function with the parameter `USE_IPV6`.
|
||||
Please note that although LibHTTP supports both IPv4 and IPv6 communication that IPv6 addressing is only available if it was enabled at compile time. When running an application it is possible to check if IPv6 support has been compiled in by using the [`httplib_check_feature()`](httplib_check_feature.md) function with the parameter `USE_IPV6`.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_close_connection();`](mg_close_connection.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_close_connection();`](httplib_close_connection.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_form_data_handler;`
|
||||
### `struct httplib_form_data_handler;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
||**`filename`** - The name of the file to upload. Please not that this parameter is only valid when the input type was set to `file`. Otherwise this parameter has the value `NULL`.|
|
||||
||**`path`** - This is an output parameter used to store the full name of the file including the path to store an incoming file at the computer. This parameter must be provided by the application to LibHTTP when a form field of type `file` is found. Please not that together with setting this parameter, the callback function must return `FORM_FIELD_STORAGE_STORE`.i With any other return value the contents of the `path` buffer is ignored by LibHTTP.|
|
||||
||**`pathlen`** - The length of the buffer where the output path can be stored.|
|
||||
||**`user_data`** - A pointer to the value of the field `user_data` of the structure `struct mg_form_data_handler`.|
|
||||
||**`user_data`** - A pointer to the value of the field `user_data` of the structure `struct httplib_form_data_handler`.|
|
||||
||The callback function `field_found()` can return the following values back to LibHTTP:|
|
||||
||**`FORM_FIELD_STORAGE_SKIP`** - Ignore the field and continue with processing the next field|
|
||||
||**`FORM_FIELD_STORAGE_GET`** - Call the callback function `field_get()` to receive the form data|
|
||||
@@ -24,13 +24,13 @@
|
||||
||**`path`** -|
|
||||
||**`file_size`** - The path on the server where the file was stored|
|
||||
||**`user_data`** - The size of the stored file in bytes|
|
||||
|**`user_data`**|**`void *`** The value of the field `user_data` when the callback functions were registered with a call to `mg_handle_form_request();`|
|
||||
|**`user_data`**|**`void *`** The value of the field `user_data` when the callback functions were registered with a call to `httplib_handle_form_request();`|
|
||||
||The `user_data` field is a user supplied argument that will be passed as parameter to each of callback functions|
|
||||
|
||||
### Description
|
||||
|
||||
The structure `struct mg_form_data_handler` contains callback functions for handling form fields. Form fields give additional information back from a web page to the server which can be processed by these callback functions.
|
||||
The structure `struct httplib_form_data_handler` contains callback functions for handling form fields. Form fields give additional information back from a web page to the server which can be processed by these callback functions.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_handle_form_request();`](mg_handle_form_request.md)
|
||||
* [`httplib_handle_form_request();`](httplib_handle_form_request.md)
|
||||
|
@@ -1,24 +1,24 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_context( conn );`
|
||||
### `httplib_get_context( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`const struct mg_connection *`|The connection for which the context has to be returned|
|
||||
|**`conn`**|`const struct httplib_connection *`|The connection for which the context has to be returned|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_context *`|A pointer to the context of the given connection|
|
||||
|`struct httplib_context *`|A pointer to the context of the given connection|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_context()` returns the context associated with a connection.
|
||||
The function `httplib_get_context()` returns the context associated with a connection.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`mg_stop();`](mg_stop.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
* [`httplib_stop();`](httplib_stop.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_cookie( cookie, var_name, buf, buf_len );`
|
||||
### `httplib_get_cookie( cookie, var_name, buf, buf_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_cookie()` tries to fetch the value of a certain cookie variable. The contents will either be stored in an application provided buffer, or an error code will be returned. The destination buffer is guaranteed to be NUL terminated if the pointer of the buffer is not a NULL pointer and the size of the buffer is at least one byte.
|
||||
The function `httplib_get_cookie()` tries to fetch the value of a certain cookie variable. The contents will either be stored in an application provided buffer, or an error code will be returned. The destination buffer is guaranteed to be NUL terminated if the pointer of the buffer is not a NULL pointer and the size of the buffer is at least one byte.
|
||||
|
||||
If the function succeeds, the return value of the function is the length in bytes of the cookie. The value **`-1`** is returned if the requested cookie could not be found and **`-2`** if the destination buffer is represented by a NULL pointer, is zero length or too short to store the whole cookie.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_var();`](mg_get_var.md)
|
||||
* [`mg_get_var2();`](mg_get_var2.md)
|
||||
* [`httplib_get_var();`](httplib_get_var.md)
|
||||
* [`httplib_get_var2();`](httplib_get_var2.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_header( conn, name );`
|
||||
### `httplib_get_header( conn, name );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`| A pointer referencing the connection |
|
||||
|**`conn`**|`struct httplib_connection *`| A pointer referencing the connection |
|
||||
|**`name`**|`const char *`| The name of the request header |
|
||||
|
||||
### Return Value
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
HTTP and HTTPS clients can send request headers to the server to provide details about the communication. These request headers can for example specify the preferred language in which the server should respond and the supported compression algorithms. The function `mg_get_header()` can be called to return the contents of a specific request header. The function will return a pointer to the value text of the header when succesful, and NULL of no matching request header from the client could be found.
|
||||
HTTP and HTTPS clients can send request headers to the server to provide details about the communication. These request headers can for example specify the preferred language in which the server should respond and the supported compression algorithms. The function `httplib_get_header()` can be called to return the contents of a specific request header. The function will return a pointer to the value text of the header when succesful, and NULL of no matching request header from the client could be found.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_header;`](mg_header.md)
|
||||
* [`mg_get_cookie();`](mg_get_cookie.md)
|
||||
* [`struct httplib_header;`](httplib_header.md)
|
||||
* [`httplib_get_cookie();`](httplib_get_cookie.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_option( ctx, name );`
|
||||
### `httplib_get_option( ctx, name );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`const struct mg_context *`| A pointer to the webserver context |
|
||||
|**`ctx`**|`const struct httplib_context *`| A pointer to the webserver context |
|
||||
|**`name`**|`const char *`| The name of the option to query |
|
||||
|
||||
### Return Value
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
When starting the LibHTTP webserver, options are provided to set the wanted behaviour of the server. The options which were used during startup can be queried through the `mg_get_option()` function. Options are read-only and cannot be changed while the webserver is running. The function returns a pointer to a text string containing the value of the queried option, or NULL if an error occured. It is guaranteed however that if a valid option name is provided as a parameter to this function, that a pointer to a string is returned and not NULL. In case an option was empty or NULL during initialisation, `mg_get_option()` will return a pointer to an empty string.
|
||||
When starting the LibHTTP webserver, options are provided to set the wanted behaviour of the server. The options which were used during startup can be queried through the `httplib_get_option()` function. Options are read-only and cannot be changed while the webserver is running. The function returns a pointer to a text string containing the value of the queried option, or NULL if an error occured. It is guaranteed however that if a valid option name is provided as a parameter to this function, that a pointer to a string is returned and not NULL. In case an option was empty or NULL during initialisation, `httplib_get_option()` will return a pointer to an empty string.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
|
@@ -1,23 +1,23 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_request_info( conn );`
|
||||
### `httplib_get_request_info( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`const struct mg_connection *`|The connection for which the request info is needed|
|
||||
|**`conn`**|`const struct httplib_connection *`|The connection for which the request info is needed|
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`const struct mg_request_info *`|Pointer to the requested info, or NULL if an error occured|
|
||||
|`const struct httplib_request_info *`|Pointer to the requested info, or NULL if an error occured|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_request_info()` returns information about the request on a given connection. This information is returned as a pointer to a [`mg_request_info`](mg_request_info.md) structure. If an error occurs, a NULL pointer is returned instead.
|
||||
The function `httplib_get_request_info()` returns information about the request on a given connection. This information is returned as a pointer to a [`httplib_request_info`](httplib_request_info.md) structure. If an error occurs, a NULL pointer is returned instead.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_request_info;`](mg_request_info.md)
|
||||
* [`struct httplib_request_info;`](httplib_request_info.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_response( conn, ebuf, ebuf_len, timeout );`
|
||||
### `httplib_get_response( conn, ebuf, ebuf_len, timeout );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection to listen on|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection to listen on|
|
||||
|**`ebuf`**|`char *`|Buffer to store an error message|
|
||||
|**`ebuf_len`**|`size_t`|Size of the error message buffer including the terminating NUL|
|
||||
|**`timeout`**|`int`|Time to wait for a response in milliseconds|
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_reponse()` wait for a response from a remote server. A return value equal or greater than zero is an indication for success, a negative value us used to signal an error condition. A timeout can be specified which lets the function return after a specified number of milliseconds, even if no data is received from the remote party. If the timeout value is negative, the function will not return until data has been read or an unrecoverable error occurs.
|
||||
The function `httplib_get_reponse()` wait for a response from a remote server. A return value equal or greater than zero is an indication for success, a negative value us used to signal an error condition. A timeout can be specified which lets the function return after a specified number of milliseconds, even if no data is received from the remote party. If the timeout value is negative, the function will not return until data has been read or an unrecoverable error occurs.
|
||||
|
||||
Error messages are stored in a caller supplied error message buffer.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_connect_client();`](mg_connect_client.md)
|
||||
* [`mg_connect_client_secure();`](mg_connect_client_secure.md)
|
||||
* [`httplib_connect_client();`](httplib_connect_client.md)
|
||||
* [`httplib_connect_client_secure();`](httplib_connect_client_secure.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_response_code_text( conn, response_code );`
|
||||
### `httplib_get_response_code_text( conn, response_code );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`| A pointer referencing the connection |
|
||||
|**`conn`**|`struct httplib_connection *`| A pointer referencing the connection |
|
||||
|**`response_code`**|`int`| Response code for which the text is queried |
|
||||
|
||||
### Return Value
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_response_code_text()` returns a pointer to a human readable text describing the HTTP response code which was provided as a parameter.
|
||||
The function `httplib_get_response_code_text()` returns a pointer to a human readable text describing the HTTP response code which was provided as a parameter.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||
* [`mg_version();`](mg_version.md)
|
||||
* [`httplib_version();`](httplib_version.md)
|
||||
|
@@ -1,14 +1,14 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_server_ports( ctx, size, ports );`
|
||||
### `httplib_get_server_ports( ctx, size, ports );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`const struct mg_context *`|The context for which the server ports are requested|
|
||||
|**`ctx`**|`const struct httplib_context *`|The context for which the server ports are requested|
|
||||
|**`size`**|`int`|The size of the buffer to store the port information|
|
||||
|**`ports`**|`struct mg_server_ports *`|Buffer to store the port information|
|
||||
|**`ports`**|`struct httplib_server_ports *`|Buffer to store the port information|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
### Description
|
||||
|
||||
The `mg_get_server_ports()` returns a list with server ports on which the LibHTTP server is listening. The ports are returned for a given context and stored with additional information like the SSL and redirection state in a list of structures. The list of structures must be allocated by the calling routine. The size of the structure is also passed to `mg_get_server_ports()`.
|
||||
The `httplib_get_server_ports()` returns a list with server ports on which the LibHTTP server is listening. The ports are returned for a given context and stored with additional information like the SSL and redirection state in a list of structures. The list of structures must be allocated by the calling routine. The size of the structure is also passed to `httplib_get_server_ports()`.
|
||||
|
||||
The function returns the number of items in the list, or a negative value if an error occured.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_server_ports;`](mg_server_ports.md)
|
||||
* [`struct httplib_server_ports;`](httplib_server_ports.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_user_connection_data( conn );`
|
||||
### `httplib_get_user_connection_data( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`const struct mg_connection *`|The connection for which to return the user data|
|
||||
|**`conn`**|`const struct httplib_connection *`|The connection for which to return the user data|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_user_connection_data()` returns the user data associated with a connection. This user data is represented with a pointer which has been prevously registered with a call to [`mg_set_user_connection_data();`](mg_set_user_connection_data.md). With this function it is possible to pass state information between callback functions refering to a specific connection.
|
||||
The function `httplib_get_user_connection_data()` returns the user data associated with a connection. This user data is represented with a pointer which has been prevously registered with a call to [`httplib_set_user_connection_data();`](httplib_set_user_connection_data.md). With this function it is possible to pass state information between callback functions refering to a specific connection.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_user_data();`](mg_get_user_data.md)
|
||||
* [`mg_set_user_connection_data();`](mg_set_user_connection_data.md)
|
||||
* [`httplib_get_user_data();`](httplib_get_user_data.md)
|
||||
* [`httplib_set_user_connection_data();`](httplib_set_user_connection_data.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_user_data( ctx );`
|
||||
### `httplib_get_user_data( ctx );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`const struct mg_context *`|The context for which the user data is requested|
|
||||
|**`ctx`**|`const struct httplib_context *`|The context for which the user data is requested|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_user_data()` returns the user data associated with a LibHTTP context. This is a pointer value which has previously been used in the call to [`mg_start()`](mg_start.md) to initialize the server context.
|
||||
The function `httplib_get_user_data()` returns the user data associated with a LibHTTP context. This is a pointer value which has previously been used in the call to [`httplib_start()`](httplib_start.md) to initialize the server context.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_user_connection_data();`](mg_get_user_connection_data.md)
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`httplib_get_user_connection_data();`](httplib_get_user_connection_data.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_valid_options();`
|
||||
### `httplib_get_valid_options();`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`const struct mg_option *`|An array with all valid configuration options|
|
||||
|`const struct httplib_option *`|An array with all valid configuration options|
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_valid_options()` returns an array with all valid configuration options of LibHTTP. Each element in the array is a structure with three fields which represent the name of the option, the value of the option and the type of the value. The array is terminated with an element for which the name is `NULL`. See for more details about this structure the documentation of [`struct mg_option`](mg_option.md).
|
||||
The function `httplib_get_valid_options()` returns an array with all valid configuration options of LibHTTP. Each element in the array is a structure with three fields which represent the name of the option, the value of the option and the type of the value. The array is terminated with an element for which the name is `NULL`. See for more details about this structure the documentation of [`struct httplib_option`](httplib_option.md).
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_option;`](mg_option.md)
|
||||
* [`mg_check_feature();`](mg_check_feature.md)
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`struct httplib_option;`](httplib_option.md)
|
||||
* [`httplib_check_feature();`](httplib_check_feature.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_var( data, data_len, var_name, dst, dst_len );`
|
||||
### `httplib_get_var( data, data_len, var_name, dst, dst_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_var()` returns the value of a variable which is passed to the server with either a POST method, or as a parameter in the URI of a GET call. The data pointer passed to the function points to a form-URI encoded buffer. This can either be POST data or the `request_info.query_string`. The name of the searched variable and a buffer to store the results are also parameters to the function.
|
||||
The function `httplib_get_var()` returns the value of a variable which is passed to the server with either a POST method, or as a parameter in the URI of a GET call. The data pointer passed to the function points to a form-URI encoded buffer. This can either be POST data or the `request_info.query_string`. The name of the searched variable and a buffer to store the results are also parameters to the function.
|
||||
|
||||
The function either returns the length of the variable when successful, **`-1`** if the variable could not be found and **`-2`** if the destination buffer is NULL, has size zero or is too small to store the resulting variable value.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_cookie();`](mg_get_cookie.md)
|
||||
* [`mg_get_var2();`](mg_get_var2.md)
|
||||
* [`httplib_get_cookie();`](httplib_get_cookie.md)
|
||||
* [`httplib_get_var2();`](httplib_get_var2.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`
|
||||
### `httplib_get_var2( data, data_len, var_name, dst, dst_len, occurrence );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -21,11 +21,11 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_get_var2()` can be used to return the contents of a variable passed to the server as either POST data, or in the URI in a GET call. The function is somilar to [`mg_get_var()`](mg_get_var.md) but the difference is that `mg_get_var2()` can be used if the same variable is present multiple times in the data. The `occurence` parameter is used to identify which instance of the variable must be returned where **`0`** is used for the first variable with the specified name, **`1`** for the second and so on.
|
||||
The function `httplib_get_var2()` can be used to return the contents of a variable passed to the server as either POST data, or in the URI in a GET call. The function is somilar to [`httplib_get_var()`](httplib_get_var.md) but the difference is that `httplib_get_var2()` can be used if the same variable is present multiple times in the data. The `occurence` parameter is used to identify which instance of the variable must be returned where **`0`** is used for the first variable with the specified name, **`1`** for the second and so on.
|
||||
|
||||
The function returns the length of the variable content in the return buffer, **`-1`** if a variable with the specified name could not be found and **`-2`** if the pointer to the result buffer is NULL, the size of the result buffer is zero or when the result buffer is too small to contain the variable content and terminating NUL.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_cookie();`](mg_get_cookie.md)
|
||||
* [`mg_get_var();`](mg_get_var.md)
|
||||
* [`httplib_get_cookie();`](httplib_get_cookie.md)
|
||||
* [`httplib_get_var();`](httplib_get_var.md)
|
||||
|
@@ -1,13 +1,13 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_handle_form_request( conn, fdh );`
|
||||
### `httplib_handle_form_request( conn, fdh );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection on which form data must be processed|
|
||||
|**`fdh`**|`struct mg_form_data_handler`|Structure with callback functions to to the heavy work|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection on which form data must be processed|
|
||||
|**`fdh`**|`struct httplib_form_data_handler`|Structure with callback functions to to the heavy work|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_handle_form_request()` processes form data on a connection. The function uses callback functions for the heavy lifting which are passed to the function as fields in a [`struct mg_form_data_handler`](mg_form_data_handler.md) structure. The number of processed fields is returned by the function, or a negative value when an error occured. I nthe situation where some fields are processed successfully (for example file downloads) and an error occurs later in the form processing, the function still returns a negative value. It is the responsibility of the calling party to do the necessary cleanup. The calling party should also do the cleanup of any files which are created, but not required anymore later.
|
||||
The function `httplib_handle_form_request()` processes form data on a connection. The function uses callback functions for the heavy lifting which are passed to the function as fields in a [`struct httplib_form_data_handler`](httplib_form_data_handler.md) structure. The number of processed fields is returned by the function, or a negative value when an error occured. I nthe situation where some fields are processed successfully (for example file downloads) and an error occurs later in the form processing, the function still returns a negative value. It is the responsibility of the calling party to do the necessary cleanup. The calling party should also do the cleanup of any files which are created, but not required anymore later.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_form_data_handler;`](mg_form_data_handler.md)
|
||||
* [`struct httplib_form_data_handler;`](httplib_form_data_handler.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_header;`
|
||||
### `struct httplib_header;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -11,9 +11,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The structure `mg_header` is used as a sub-structure in the [`struct mg_request_info;`](mg_request_info.md) structure to store the name and value of one HTTP request header as sent by the client.
|
||||
The structure `httplib_header` is used as a sub-structure in the [`struct httplib_request_info;`](httplib_request_info.md) structure to store the name and value of one HTTP request header as sent by the client.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_request_info;`](mg_request_info.md)
|
||||
* [`mg_get_header();`](mg_get_header.md)
|
||||
* [`struct httplib_request_info;`](httplib_request_info.md)
|
||||
* [`httplib_get_header();`](httplib_get_header.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_lock_connection( conn );`
|
||||
### `httplib_lock_connection( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection to retrieve a lock|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection to retrieve a lock|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_lock_connection()` is specifically for websocket connections to lock connection. Using this function in combination with [`mg_unlock_connection();`](mg_unlock_connection.md) is necessary around [`mg_write()`](mg_write.md) and [`mg_printf()`](mg_printf.md) calls if the code has server-initiated communication, as well as with communication in direct response to a message.
|
||||
The function `httplib_lock_connection()` is specifically for websocket connections to lock connection. Using this function in combination with [`httplib_unlock_connection();`](httplib_unlock_connection.md) is necessary around [`httplib_write()`](httplib_write.md) and [`httplib_printf()`](httplib_printf.md) calls if the code has server-initiated communication, as well as with communication in direct response to a message.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_context();`](mg_lock_context.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`mg_unlock_context();`](mg_unlock_context.md)
|
||||
* [`mg_websocket_client_write();`](mg_websocket_client_write.md)
|
||||
* [`mg_websocket_write();`](mg_websocket_write.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_lock_context();`](httplib_lock_context.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
* [`httplib_unlock_context();`](httplib_unlock_context.md)
|
||||
* [`httplib_websocket_client_write();`](httplib_websocket_client_write.md)
|
||||
* [`httplib_websocket_write();`](httplib_websocket_write.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_lock_context( ctx );`
|
||||
### `httplib_lock_context( ctx );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`struct mg_context *`|The context to put the lock on|
|
||||
|**`ctx`**|`struct httplib_context *`|The context to put the lock on|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_lock_context()` can be used to acquire a lock for exclusive access to resources which are shared between connection of threads. The lock is context wide. The lock must be released with a call to [`mg_unlock_context()`](mg_unlock_context.md).
|
||||
The function `httplib_lock_context()` can be used to acquire a lock for exclusive access to resources which are shared between connection of threads. The lock is context wide. The lock must be released with a call to [`httplib_unlock_context()`](httplib_unlock_context.md).
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`mg_unlock_context();`](mg_unlock_context.md)
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
* [`httplib_unlock_context();`](httplib_unlock_context.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_md5( buf, ... );`
|
||||
### `httplib_md5( buf, ... );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_md5()` caluclates the MD5 checksum of a NULL terminated list of NUL terminated ASCII strings. The MD5 checksum is returned in human readable format as an MD5 string in a caller supplied buffer.
|
||||
The function `httplib_md5()` caluclates the MD5 checksum of a NULL terminated list of NUL terminated ASCII strings. The MD5 checksum is returned in human readable format as an MD5 string in a caller supplied buffer.
|
||||
|
||||
The function returns a pointer to the supplied result buffer.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_modify_passwords_file();`](mg_modify_passwords_file.md)
|
||||
* [`httplib_modify_passwords_file();`](httplib_modify_passwords_file.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_modify_passwords_file( passwords_file_name, domain, user, password );`
|
||||
### `httplib_modify_passwords_file( passwords_file_name, domain, user, password );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_modify_passwords_file()` allows an application to manipulate .htpasswd files on the fly by adding, deleting and changing user records. This is one of the several ways to implement authentication on the server side.
|
||||
The function `httplib_modify_passwords_file()` allows an application to manipulate .htpasswd files on the fly by adding, deleting and changing user records. This is one of the several ways to implement authentication on the server side.
|
||||
|
||||
If the password parameter is not `NULL` an entry is added to the password file. An existing records is modified in that case. If `NULL` is used as the password the enrty is removed from the file.
|
||||
|
||||
@@ -27,4 +27,4 @@ The function returns 1 when successful and 0 if an error occurs.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_md5();`](mg_md5.md)
|
||||
* [`httplib_md5();`](httplib_md5.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_option;`
|
||||
### `struct httplib_option;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
### Description
|
||||
|
||||
A list of valid configuration options of the LibHTTP instance can be retrieved with a call to [`mg_get_valid_options()`](mg_get_valid_options.md). This function fills a list of `struct mg_option` structures where the content of each structure represents a configuration option. Each structure contains three fields. One field contains the name of the option, the second contains the value of the option and the third is an identifier used to define the type of the option and how the value contents should be interpreted.
|
||||
A list of valid configuration options of the LibHTTP instance can be retrieved with a call to [`httplib_get_valid_options()`](httplib_get_valid_options.md). This function fills a list of `struct httplib_option` structures where the content of each structure represents a configuration option. Each structure contains three fields. One field contains the name of the option, the second contains the value of the option and the third is an identifier used to define the type of the option and how the value contents should be interpreted.
|
||||
|
||||
The field `type` can be one of the following values:
|
||||
|
||||
@@ -28,4 +28,4 @@ The field `type` can be one of the following values:
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_valid_options();`](mg_get_valid_options.md)
|
||||
* [`httplib_get_valid_options();`](httplib_get_valid_options.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_printf( conn, fmt, ... );`
|
||||
### `httplib_printf( conn, fmt, ... );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection over which the data must be sent|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection over which the data must be sent|
|
||||
|**`fmt`**|`const char *`|Format string|
|
||||
|**`...`**|*various*|Parameters as specified in the format string|
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_printf()` can be used to send formatted strings over a connection. The functionality is comparable to the `printf()` family of functions in the standard C library. The function returns **0** when the connection has been closed, **-1** if an error occurred and otherwise the number of bytes written over the connection. Except for the formatting part, the `mg_printf()` function is identical to the function [`mg_write()`](mg_write.md).
|
||||
The function `httplib_printf()` can be used to send formatted strings over a connection. The functionality is comparable to the `printf()` family of functions in the standard C library. The function returns **0** when the connection has been closed, **-1** if an error occurred and otherwise the number of bytes written over the connection. Except for the formatting part, the `httplib_printf()` function is identical to the function [`httplib_write()`](httplib_write.md).
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_websocket_client_write();`](mg_websocket_client_write.md)
|
||||
* [`mg_websocket_write();`](mg_websocket_write.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_websocket_client_write();`](httplib_websocket_client_write.md)
|
||||
* [`httplib_websocket_write();`](httplib_websocket_write.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,26 +0,0 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_read( conn, buf, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`| A pointer referencing the connection |
|
||||
|**`buf`**|`void *`| A pointer to the location where the received data can be stored |
|
||||
|**`len`**|`size_t`| The maximum number of bytes to be stored in the buffer |
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`| The number of read bytes, or a status indication |
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_read()` receives data over an existing connection. The data is handled as binary and is stored in a buffer whose address has been provided as a parameter. The function returns the number of read bytes when successful, the value **0** when the connection has been closed by peer and a negative value when no more data could be read from the connection.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_write();`](mg_write.md)
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_request_info;`
|
||||
### `struct httplib_request_info;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
|**`content_length`**|`long long`| The content length of the request body. This value can be -1 if no content length was provided. |
|
||||
|**`remote_port`**|`int`| The port number at the client's side |
|
||||
|**`is_ssl`**|`int`| 1 if the connection is over SSL, and 0 if it is a plain connection |
|
||||
|**`user_data`**|`void *`| A pointer to the `user_data` information which was provided as a parameter to `mg_start()`. |
|
||||
|**`user_data`**|`void *`| A pointer to the `user_data` information which was provided as a parameter to `httplib_start()`. |
|
||||
|**`conn_data`**|`void *`| A pointer to connection specific user data |
|
||||
|**`num_headers`**|`int`| The number of HTTP request headers sent by the client |
|
||||
|**`http_headers`**|`struct mg_header[64]`| Array of structures with the HTTP request headers sent by the client |
|
||||
|**`http_headers`**|`struct httplib_header[64]`| Array of structures with the HTTP request headers sent by the client |
|
||||
|**`client_cert`**|`struct client_cert *`| Pointer to the client certificate information, when available |
|
||||
|
||||
### Description
|
||||
|
||||
The `mg_request_info` structure contains the client information of an existing connection.
|
||||
The `httplib_request_info` structure contains the client information of an existing connection.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct client_cert;`](client_cert.md)
|
||||
* [`struct mg_header;`](mg_header.md)
|
||||
* [`mg_get_request_info();`](mg_get_request_info.md)
|
||||
* [`struct httplib_header;`](httplib_header.md)
|
||||
* [`httplib_get_request_info();`](httplib_get_request_info.md)
|
||||
|
@@ -1,25 +0,0 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_send_file( conn, path );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection over which the file must be sent|
|
||||
|**`path`**|`const char *`|The full path and filename of the file|
|
||||
|
||||
### Return Value
|
||||
|
||||
*none*
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_send_file()` sends the contents of a file over a connection to the remote peer. The function also adds the necessary HTTP headers.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_send_mime_file();`](mg_send_mime_file.md)
|
||||
* [`mg_send_mime_file2();`](mg_send_mime_file2.md)
|
||||
* [`mg_write();`](mg_write.md)
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_send_mime_file( conn, path, mime_type );`
|
||||
### `httplib_send_mime_file( conn, path, mime_type );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection over which the file must be sent|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection over which the file must be sent|
|
||||
|**`path`**|`const char *`|The full path and filename of the file|
|
||||
|**`mime_type`**|`const char *`|The mime type of the file, or NULL for automatic detection|
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_send_mime_file()` sends a file over a connection including the HTTP headers. The function is similar to the [`mg_send_file()`](mg_send_file.md) with the additional functionality that the MIME type of the file can be specified. If the `mime_type` parameter is NULL, the routine will try to determine the MIME type based on the extension of the filename.
|
||||
The function `httplib_send_mime_file()` sends a file over a connection including the HTTP headers. The function is similar to the [`httplib_send_file()`](httplib_send_file.md) with the additional functionality that the MIME type of the file can be specified. If the `mime_type` parameter is NULL, the routine will try to determine the MIME type based on the extension of the filename.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_send_file();`](mg_send_file.md)
|
||||
* [`mg_send_mime_file2();`](mg_send_mime_file2.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_send_file();`](httplib_send_file.md)
|
||||
* [`httplib_send_mime_file2();`](httplib_send_mime_file2.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_send_mime_file2( conn, path, mime_type, additional_headers );`
|
||||
### `httplib_send_mime_file2( conn, path, mime_type, additional_headers );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|The connection over which the file must be sent|
|
||||
|**`conn`**|`struct httplib_connection *`|The connection over which the file must be sent|
|
||||
|**`path`**|`const char *`|The full path and filename of the file|
|
||||
|**`mime_type`**|`const char *`|The mime type or NULL for automatic detection|
|
||||
|**`additional_headers`**|`const char *`|Additional headers to be sent|
|
||||
@@ -17,14 +17,14 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_send_mime_file2()` can be used to send a file over a connection. The function is similar to [`mg_send_mime_file()`](mg_send_mime_file.md) with the additional functionality that user specified headers can be sent. The MIME type of the file can be specified in the function call, or will be automatically determined based on the extension of the filename if the `mime_type` parameter has the value NULL.
|
||||
The function `httplib_send_mime_file2()` can be used to send a file over a connection. The function is similar to [`httplib_send_mime_file()`](httplib_send_mime_file.md) with the additional functionality that user specified headers can be sent. The MIME type of the file can be specified in the function call, or will be automatically determined based on the extension of the filename if the `mime_type` parameter has the value NULL.
|
||||
|
||||
Additional custom header fields can be added as a parameter. Please make sure that these header names begin with `X-` to prevent name clashes with other headers. If the `additional_headers` parameter is NULL, no custom headers will be added.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`httplib_get_builtin_mime_type();`](httplib_get_builtin_mime_type.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_send_file();`](mg_send_file.md)
|
||||
* [`mg_send_mime_file();`](mg_send_mime_file.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_send_file();`](httplib_send_file.md)
|
||||
* [`httplib_send_mime_file();`](httplib_send_mime_file.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `struct mg_server_ports;`
|
||||
### `struct httplib_server_ports;`
|
||||
|
||||
### Fields
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
A call to the function [`mg_get_server_ports()`](mg_get_server_ports.md) returns a list of structures with information about each running LibHTTP service. These structures are of type `struct mg_server_ports` and contain the base information of each service.
|
||||
A call to the function [`httplib_get_server_ports()`](httplib_get_server_ports.md) returns a list of structures with information about each running LibHTTP service. These structures are of type `struct httplib_server_ports` and contain the base information of each service.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_server_ports();`](mg_get_server_ports.md)
|
||||
* [`httplib_get_server_ports();`](httplib_get_server_ports.md)
|
||||
|
@@ -1,17 +1,17 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_set_auth_handler( ctx, uri, handler, cbdata );`
|
||||
### `httplib_set_auth_handler( ctx, uri, handler, cbdata );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`struct mg_context *`|The context on which the handler must be set|
|
||||
|**`ctx`**|`struct httplib_context *`|The context on which the handler must be set|
|
||||
|**`uri`**|`const char *`|The URI for the authorization handler|
|
||||
|**`handler`**|`mg_authorization_handler`|Callback function doing the actual authorization|
|
||||
|**`handler`**|`httplib_authorization_handler`|Callback function doing the actual authorization|
|
||||
|**`cbdata`**|`void *`|Optional user data|
|
||||
|
||||
`int mg_authorization_handler( struct mg_connection *conn, void *cbdata );`
|
||||
`int httplib_authorization_handler( struct httplib_connection *conn, void *cbdata );`
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -19,12 +19,12 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_set_auth_handler()` hooks an authorization function to an URI to check if a user is authorized to visit that URI. The check is performed by a callback function of type `mg_authorization_handler`. The callback function is passed two parameters: the current connection and a pointer to optional user defined data which was passed to `mg_set_auth_handler()` when the callback was hooked to the URI.
|
||||
The function `httplib_set_auth_handler()` hooks an authorization function to an URI to check if a user is authorized to visit that URI. The check is performed by a callback function of type `httplib_authorization_handler`. The callback function is passed two parameters: the current connection and a pointer to optional user defined data which was passed to `httplib_set_auth_handler()` when the callback was hooked to the URI.
|
||||
|
||||
The callback function can return **0** to deny access, and **1** to allow access.
|
||||
|
||||
The `mg_set_auth_handler()` function is very similar in use to [`mg_set_request_handler()`](mg_set_request_handler.md).
|
||||
The `httplib_set_auth_handler()` function is very similar in use to [`httplib_set_request_handler()`](httplib_set_request_handler.md).
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_set_request_handler();`](mg_set_request_handler.md)
|
||||
* [`httplib_set_request_handler();`](httplib_set_request_handler.md)
|
||||
|
@@ -1,17 +1,17 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_set_request_handler( ctx, uri, handler, cbdata );`
|
||||
### `httplib_set_request_handler( ctx, uri, handler, cbdata );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`struct mg_context *`|The context where the handler must be active|
|
||||
|**`ctx`**|`struct httplib_context *`|The context where the handler must be active|
|
||||
|**`uri`**|`const char *`|The URI to hook the handler on|
|
||||
|**`handler`**|`mg_request_handler`|Callback function doing the heavy lifting|
|
||||
|**`handler`**|`httplib_request_handler`|Callback function doing the heavy lifting|
|
||||
|**`cbdata`**|`void *`|Optional user supplied data|
|
||||
|
||||
`int mg_request_handler( struct mg_connection *conn, void *cbdata );`
|
||||
`int httplib_request_handler( struct httplib_connection *conn, void *cbdata );`
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_set_request_handler()` hooks a callback function on a URI. That callback function is called whenever a client requests the specific URI. The callback function receives the connection information and optional user supplied data as parameters and can serve information back to the client. When the callback function does not send any information back to the client, it should return **0** to signal LibHTTP that the LibHTTP core should handle the request. A return value between 1 and 999 is used to tell LibHTTP that the request has been handled and no further processing is necessary. The returned code is stored as the status code in the access log, it is therefore recommended, although not mandatory to return a status code which matches the state of the request.
|
||||
The function `httplib_set_request_handler()` hooks a callback function on a URI. That callback function is called whenever a client requests the specific URI. The callback function receives the connection information and optional user supplied data as parameters and can serve information back to the client. When the callback function does not send any information back to the client, it should return **0** to signal LibHTTP that the LibHTTP core should handle the request. A return value between 1 and 999 is used to tell LibHTTP that the request has been handled and no further processing is necessary. The returned code is stored as the status code in the access log, it is therefore recommended, although not mandatory to return a status code which matches the state of the request.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_set_auth_handler();`](mg_set_auth_handler.md)
|
||||
* [`httplib_set_auth_handler();`](httplib_set_auth_handler.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_set_user_connection_data( conn, data );`
|
||||
### `httplib_set_user_connection_data( conn, data );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|connection to add the user data|
|
||||
|**`conn`**|`struct httplib_connection *`|connection to add the user data|
|
||||
|**`data`**|`void *`|Pointer to the user data|
|
||||
|
||||
### Return Value
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_set_user_connection_data()` can be used to add or change the user data pointer attached to a connection. Using the value NULL in the call will remove a previously assigned user data pointer.
|
||||
The function `httplib_set_user_connection_data()` can be used to add or change the user data pointer attached to a connection. Using the value NULL in the call will remove a previously assigned user data pointer.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_get_user_connection_data();`](mg_user_connection_data.md)
|
||||
* [`httplib_get_user_connection_data();`](httplib_user_connection_data.md)
|
||||
|
@@ -1,23 +1,23 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_set_websocket_handler( ctx, uri, connect_handler, ready_handler, data_handler, close_handler, cbdata );`
|
||||
### `httplib_set_websocket_handler( ctx, uri, connect_handler, ready_handler, data_handler, close_handler, cbdata );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`mg_context *`|The context in which to add the handlers|
|
||||
|**`ctx`**|`httplib_context *`|The context in which to add the handlers|
|
||||
|**`uri`**|`const char *`|The URI for which the handlers should be activated|
|
||||
|**`connect_handler`**|`mg_websocket_connect_handler`|Handler called when a connect is signalled|
|
||||
|**`ready_handler`**|`mg_websocket_ready_handler`|Handler called when the connection is ready|
|
||||
|**`data_handler`**|`mg_websocket_data_handler`|Handler called when data is received|
|
||||
|**`close_handler`**|`mg_websocket_close_handler`|Handler called when the connection closes|
|
||||
|**`connect_handler`**|`httplib_websocket_connect_handler`|Handler called when a connect is signalled|
|
||||
|**`ready_handler`**|`httplib_websocket_ready_handler`|Handler called when the connection is ready|
|
||||
|**`data_handler`**|`httplib_websocket_data_handler`|Handler called when data is received|
|
||||
|**`close_handler`**|`httplib_websocket_close_handler`|Handler called when the connection closes|
|
||||
|**`cbdata`**|`void *`|User defined data|
|
||||
|
||||
`int mg_websocket_connect_handler( const struct mg_connection *conn, void *cbdata );`
|
||||
`int mg_websocket_ready_handler( struct mg_connection *conn, void *cbdata );`
|
||||
`int mg_websocket_data_handler( struct mg_connection *conn, int opcode, char * buf, size_t buf_len, void *cbdata );`
|
||||
`int mg_websocket_close_handler( const struct mg_connection *conn, void *cbdata );`
|
||||
`int httplib_websocket_connect_handler( const struct httplib_connection *conn, void *cbdata );`
|
||||
`int httplib_websocket_ready_handler( struct httplib_connection *conn, void *cbdata );`
|
||||
`int httplib_websocket_data_handler( struct httplib_connection *conn, int opcode, char * buf, size_t buf_len, void *cbdata );`
|
||||
`int httplib_websocket_close_handler( const struct httplib_connection *conn, void *cbdata );`
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_set_websocket_handler()` connects callback functions to a websocket URI. The callback functions are called when a state change is detected on the URI like an incomming connection or data received from a remote peer.
|
||||
The function `httplib_set_websocket_handler()` connects callback functions to a websocket URI. The callback functions are called when a state change is detected on the URI like an incomming connection or data received from a remote peer.
|
||||
|
||||
### See Also
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_start( callbacks, user_data, options );`
|
||||
### `httplib_start( callbacks, user_data, options );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`callbacks`**|`const struct mg_callbacks *`| A structure with optional callback functions to process requests from the web server |
|
||||
|**`callbacks`**|`const struct httplib_callbacks *`| A structure with optional callback functions to process requests from the web server |
|
||||
|**`user_data`**|`void *`| A pointer to optional user data |
|
||||
|**`options`**|`char **`| A list of options used to initialize the web server. The list consists of an NULL terminated list of option-value string pairs. |
|
||||
|
||||
@@ -25,15 +25,15 @@ The option list can be used to set the following options:
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`struct mg_context *`| A pointer to a context structure when successful, or NULL in case of failure |
|
||||
|`struct httplib_context *`| A pointer to a context structure when successful, or NULL in case of failure |
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_start()` is the only function needed to call to initialize the webserver. After the function returns and a pointer to a context structure is provided, it is guaranteed that the server has started and is listening on the designated ports. In case of failure a NULL pointer is returned. The behaviour of the web server is controlled by a list of callback functions and a list of options. The callback functions can do application specific processing of events which are encountered by the webserver. If a specific callback function is set to NULL, the webserver uses their default callback routine. The options list controls how the webserver should be started and contains settings for for example the ports to listen on, the maximum number of threads created to handle requests in parallel and if settings for SSL encryption.
|
||||
The function `httplib_start()` is the only function needed to call to initialize the webserver. After the function returns and a pointer to a context structure is provided, it is guaranteed that the server has started and is listening on the designated ports. In case of failure a NULL pointer is returned. The behaviour of the web server is controlled by a list of callback functions and a list of options. The callback functions can do application specific processing of events which are encountered by the webserver. If a specific callback function is set to NULL, the webserver uses their default callback routine. The options list controls how the webserver should be started and contains settings for for example the ports to listen on, the maximum number of threads created to handle requests in parallel and if settings for SSL encryption.
|
||||
|
||||
As a side effect on Unix systems, SIGCHLD and SIGPIPE signals will be ignored. If custom processing is needed for these signals, signal handlers must be setup after the call to `mg_start()` has completed.
|
||||
As a side effect on Unix systems, SIGCHLD and SIGPIPE signals will be ignored. If custom processing is needed for these signals, signal handlers must be setup after the call to `httplib_start()` has completed.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`struct mg_callbacks;`](mg_callbacks.md)
|
||||
* [`mg_stop();`](mg_stop.md)
|
||||
* [`struct httplib_callbacks;`](httplib_callbacks.md)
|
||||
* [`httplib_stop();`](httplib_stop.md)
|
||||
|
@@ -1,15 +1,15 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_start_thread( func, cbdata );`
|
||||
### `httplib_start_thread( func, cbdata );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`func`**|`mg_thread_func_t`|Function to start as a separate thread|
|
||||
|**`func`**|`httplib_thread_func_t`|Function to start as a separate thread|
|
||||
|**`cbdata`**|`void *`|User defined data to be passed to the thread as parameter|
|
||||
|
||||
`void mg_thread_func_t( void *cbdata );`
|
||||
`void httplib_thread_func_t( void *cbdata );`
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -19,8 +19,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_start_thread()` is a convenience function to create a detached thread. The function returns **0** when successful and another value if an error occured. A pointer to user supplied data can be passed which is then passed further on to the thread function as parameter.
|
||||
The function `httplib_start_thread()` is a convenience function to create a detached thread. The function returns **0** when successful and another value if an error occured. A pointer to user supplied data can be passed which is then passed further on to the thread function as parameter.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_stop( ctx );`
|
||||
### `httplib_stop( ctx );`
|
||||
|
||||
#### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|**`struct mg_context *`**| A pointer to the current webserver context |
|
||||
|**`ctx`**|**`struct httplib_context *`**| A pointer to the current webserver context |
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_stop()` is used to stop and cleanup a running webserver. A pointer to the context of the running webserver is provided as a parameter. The execution of this function may take some time because it waits until all threads have stopped and returns all memory to the heap. After the function returns, the location the context pointer points to is invalid. The function does not return a return value and it is therefore not possible to know if stopping the webserver succeeded or not.
|
||||
The function `httplib_stop()` is used to stop and cleanup a running webserver. A pointer to the context of the running webserver is provided as a parameter. The execution of this function may take some time because it waits until all threads have stopped and returns all memory to the heap. After the function returns, the location the context pointer points to is invalid. The function does not return a return value and it is therefore not possible to know if stopping the webserver succeeded or not.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_start();`](mg_start.md)
|
||||
* [`mg_start_thread();`](mg_start_thread.md)
|
||||
* [`httplib_start();`](httplib_start.md)
|
||||
* [`httplib_start_thread();`](httplib_start_thread.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_store_body( conn, path );`
|
||||
### `httplib_store_body( conn, path );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|connection on which to read the data|
|
||||
|**`conn`**|`struct httplib_connection *`|connection on which to read the data|
|
||||
|**`path`**|`const char *`|file to store the request body|
|
||||
|
||||
### Return Value
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_store_body()` stores the body of an incoming request to a data file. The function returns the number of bytes stored in the file, or a negative value to indicate an error.
|
||||
The function `httplib_store_body()` stores the body of an incoming request to a data file. The function returns the number of bytes stored in the file, or a negative value to indicate an error.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_read();`](mg_read.md)
|
||||
* [`httplib_read();`](httplib_read.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_strcasecmp( s1, s2 );`
|
||||
### `httplib_strcasecmp( s1, s2 );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_strcasecmp()` is a helper function to compare two strings. The comparison is case insensitive. The return value is **0** if both strings are equal, less then zero if the first string is less than the second in a lexical comparison, and greater than zero if the first string is greater than the second.
|
||||
The function `httplib_strcasecmp()` is a helper function to compare two strings. The comparison is case insensitive. The return value is **0** if both strings are equal, less then zero if the first string is less than the second in a lexical comparison, and greater than zero if the first string is greater than the second.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_strncasecmp();`](mg_strncasecmp.md)
|
||||
* [`httplib_strncasecmp();`](httplib_strncasecmp.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_strncasecmp( s1, s2, len );`
|
||||
### `httplib_strncasecmp( s1, s2, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_strncasecmp()` is a helper function to compare two strings. The comparison is case insensitive and only a limited number of characters are compared. This limit is provided as third parameter in the function call. The return value is **0** if both strings are equal, less then zero if the first string is less than the second in a lexical comparison, and greater than zero if the first string is greater than the second.
|
||||
The function `httplib_strncasecmp()` is a helper function to compare two strings. The comparison is case insensitive and only a limited number of characters are compared. This limit is provided as third parameter in the function call. The return value is **0** if both strings are equal, less then zero if the first string is less than the second in a lexical comparison, and greater than zero if the first string is greater than the second.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_strcasecmp();`](mg_strcasecmp.md)
|
||||
* [`httplib_strcasecmp();`](httplib_strcasecmp.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# Libhttp API Reference
|
||||
|
||||
### `mg_unlock_connection( conn );`
|
||||
### `httplib_unlock_connection( conn );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|Connection to remove the lock from|
|
||||
|**`conn`**|`struct httplib_connection *`|Connection to remove the lock from|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_unlock_connection()` removes the lock on a connection which was previously set with a call to [`mg_lock_connection()`](mg_lock_connection.md). Locking may be necessary when using [`mg_write()`](mg_write.md) or [`mg_printf()`](mg_printf.md) on websocket connections to prevent data corruption.
|
||||
The function `httplib_unlock_connection()` removes the lock on a connection which was previously set with a call to [`httplib_lock_connection()`](httplib_lock_connection.md). Locking may be necessary when using [`httplib_write()`](httplib_write.md) or [`httplib_printf()`](httplib_printf.md) on websocket connections to prevent data corruption.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_lock_context();`](mg_lock_context.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_unlock_context();`](mg_unlock_context.md)
|
||||
* [`mg_websocket_client_write();`](mg_websocket_client_write.md)
|
||||
* [`mg_websocket_write();`](mg_websocket_write.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_lock_context();`](httplib_lock_context.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_unlock_context();`](httplib_unlock_context.md)
|
||||
* [`httplib_websocket_client_write();`](httplib_websocket_client_write.md)
|
||||
* [`httplib_websocket_write();`](httplib_websocket_write.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_unlock_context( ctx );`
|
||||
### `httplib_unlock_context( ctx );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`ctx`**|`struct mg_context *`|The context to remove the lock from|
|
||||
|**`ctx`**|`struct httplib_context *`|The context to remove the lock from|
|
||||
|
||||
### Return Value
|
||||
|
||||
@@ -14,10 +14,10 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_unlock_contect()` removes a lock put previously on a context with a call to [`mg_lock_context()`](mg_lock_context.md). Locking a context may be necessary when accessing shared resources.
|
||||
The function `httplib_unlock_contect()` removes a lock put previously on a context with a call to [`httplib_lock_context()`](httplib_lock_context.md). Locking a context may be necessary when accessing shared resources.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_lock_context();`](mg_lock_context.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_lock_context();`](httplib_lock_context.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );`
|
||||
### `httplib_url_decode( src, src_len, dst, dst_len, is_form_url_encoded );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_url_decode()` Decodes a in input buffer. Both normal URIs and form URIs can be decoded. In the latter case the space character is converted to a `+` as defined in [RFC 1866](http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt) in section 8.2.1.
|
||||
The function `httplib_url_decode()` Decodes a in input buffer. Both normal URIs and form URIs can be decoded. In the latter case the space character is converted to a `+` as defined in [RFC 1866](http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt) in section 8.2.1.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_url_encode();`](mg_url_encode.md)
|
||||
* [`httplib_url_encode();`](httplib_url_encode.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_url_encode( src, dst, des_len );`
|
||||
### `httplib_url_encode( src, dst, des_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_url_encode()` encodes a in input buffer. Both normal URIs and form URIs can be encoded. In the latter case the space character is converted to a `+` as defined in [RFC 1866](http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt) in section 8.2.1.
|
||||
The function `httplib_url_encode()` encodes a in input buffer. Both normal URIs and form URIs can be encoded. In the latter case the space character is converted to a `+` as defined in [RFC 1866](http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt) in section 8.2.1.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_url_decode();`](mg_url_decode.md)
|
||||
* [`httplib_url_decode();`](httplib_url_decode.md)
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_version();`
|
||||
### `httplib_version();`
|
||||
|
||||
### Parameters
|
||||
|
||||
@@ -14,6 +14,6 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_version()` can be used to return the current LibHTTP version. The function returns a pointer to a string with the current major and minor version number separated with a dot, for example "1.9".
|
||||
The function `httplib_version()` can be used to return the current LibHTTP version. The function returns a pointer to a string with the current major and minor version number separated with a dot, for example "1.9".
|
||||
|
||||
### See Also
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_websocket_client_write( conn, opcode, data, data_len );`
|
||||
### `httplib_websocket_client_write( conn, opcode, data, data_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|Connection on which to send data|
|
||||
|**`conn`**|`struct httplib_connection *`|Connection on which to send data|
|
||||
|**`opcode`**|`int`|Opcode|
|
||||
|**`data const`**|`char *`|The data to be written|
|
||||
|**`data_len`**|`size_t`|Length of the data buffer|
|
||||
@@ -19,14 +19,14 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_websocket_client_write()` sends data to a websocket server wrapped in a masked websocket frame. The function issues calls to [`mg_lock_connection()`](mg_lock_connection.md) and [`mg_unlock_connection()`](mg_unlock_connection.md) to ensure that the transmission is not interrupted. Interruption can happen the the application is proactively communicating and responding to a request simultaneously. This function is available only, if LibHTTP is compiled with the option `-DUSE_WEBSOCKET`.
|
||||
The function `httplib_websocket_client_write()` sends data to a websocket server wrapped in a masked websocket frame. The function issues calls to [`httplib_lock_connection()`](httplib_lock_connection.md) and [`httplib_unlock_connection()`](httplib_unlock_connection.md) to ensure that the transmission is not interrupted. Interruption can happen the the application is proactively communicating and responding to a request simultaneously. This function is available only, if LibHTTP is compiled with the option `-DUSE_WEBSOCKET`.
|
||||
|
||||
The return value is the number of bytes written on success, **0** when the connection has been closed and **-1** if an error occured.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`mg_websocket_write();`](mg_websocket_write.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
* [`httplib_websocket_write();`](httplib_websocket_write.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_websocket_write( conn, opcode, data, data_len );`
|
||||
### `httplib_websocket_write( conn, opcode, data, data_len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`|Connection on which the data must be written|
|
||||
|**`conn`**|`struct httplib_connection *`|Connection on which the data must be written|
|
||||
|**`opcode`**|`int`|Opcode|
|
||||
|**`data`**|`const char *`|Data to be written to the client|
|
||||
|**`data_len`**|`size_t`|Length of the data|
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_websocket_write()` sends data to a websocket client wrapped in a websocket frame. The function issues calls to [`mg_lock_connection()`](mg_lock_connection.md) and [`mg_unlock_connaction()`](mg_unlock_connection.md) to ensure that the transmission is not interrupted. Data corruption can otherwise happn if the application is proactively communicating and responding to a request simultaneously.
|
||||
The function `httplib_websocket_write()` sends data to a websocket client wrapped in a websocket frame. The function issues calls to [`httplib_lock_connection()`](httplib_lock_connection.md) and [`httplib_unlock_connaction()`](httplib_unlock_connection.md) to ensure that the transmission is not interrupted. Data corruption can otherwise happn if the application is proactively communicating and responding to a request simultaneously.
|
||||
|
||||
The function is available only when LibHTTP is compiled with the `-DUSE_WEBSOCKET` option.
|
||||
|
||||
@@ -27,8 +27,8 @@ The function returns the number of bytes written, **0** when the connection has
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_printf();`](mg_printf.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`mg_websocket_client_write();`](mg_websocket_client_write.md)
|
||||
* [`mg_write();`](mg_write.md)
|
||||
* [`httplib_lock_connection();`](httplib_lock_connection.md)
|
||||
* [`httplib_printf();`](httplib_printf.md)
|
||||
* [`httplib_unlock_connection();`](httplib_unlock_connection.md)
|
||||
* [`httplib_websocket_client_write();`](httplib_websocket_client_write.md)
|
||||
* [`httplib_write();`](httplib_write.md)
|
||||
|
@@ -1,29 +0,0 @@
|
||||
# LibHTTP API Reference
|
||||
|
||||
### `mg_write( conn, buf, len );`
|
||||
|
||||
### Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| :--- | :--- | :--- |
|
||||
|**`conn`**|`struct mg_connection *`| A pointer to the connection to be used to send data |
|
||||
|**`buf`**|`const void *`| A pointer to the blob of information to be sent |
|
||||
|**`len`**|`size_t`| The amount of bytes to be sent |
|
||||
|
||||
### Return Value
|
||||
|
||||
| Type | Description |
|
||||
| :--- | :--- |
|
||||
|`int`| An integer indicating the amount of bytes sent, or failure |
|
||||
|
||||
### Description
|
||||
|
||||
The function `mg_write()` can be used to send a blob of arbitrary data over a connection. The size of the data is provided as a parameter. The only length limitation on this function is `MAX_INT`, because the return value of this function will turn negative with larger blocks of data, although they may have been sent correctly. The function returns the amount of bytes sent in case of success, the value **0** when the connection has been closed, and **-1** in case of an error.
|
||||
|
||||
### See Also
|
||||
|
||||
* [`mg_lock_connection();`](mg_lock_connection.md)
|
||||
* [`mg_printf();`](mg_print.md)
|
||||
* [`mg_unlock_connection();`](mg_unlock_connection.md)
|
||||
* [`mg_websocket_client_write();`](mg_websocket_client_write.md)
|
||||
* [`mg_websocket_write();`](mg_websocket_write.md)
|
Reference in New Issue
Block a user