mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-07 16:02:55 +03:00
Callbacks can lock the context
This commit is contained in:
@@ -283,18 +283,18 @@ struct lh_rqi_t { /* */
|
|||||||
/* invoke. For a detailed description, see */
|
/* invoke. For a detailed description, see */
|
||||||
/* https://github.com/lammertb/libhttp/blob/master/docs/UserManual.md */
|
/* https://github.com/lammertb/libhttp/blob/master/docs/UserManual.md */
|
||||||
struct lh_clb_t { /* */
|
struct lh_clb_t { /* */
|
||||||
int (*begin_request)( const struct lh_ctx_t *ctx, struct lh_con_t *conn ); /* */
|
int (*begin_request)( struct lh_ctx_t *ctx, struct lh_con_t *conn ); /* */
|
||||||
void (*end_request)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, int reply_status_code ); /* */
|
void (*end_request)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, int reply_status_code ); /* */
|
||||||
int (*log_message)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */
|
int (*log_message)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */
|
||||||
int (*log_access)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */
|
int (*log_access)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *message ); /* */
|
||||||
int (*init_ssl)( const struct lh_ctx_t *ctx, void *ssl_context, void *user_data ); /* */
|
int (*init_ssl)( struct lh_ctx_t *ctx, void *ssl_context, void *user_data ); /* */
|
||||||
void (*connection_close)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn ); /* */
|
void (*connection_close)( struct lh_ctx_t *ctx, const struct lh_con_t *conn ); /* */
|
||||||
const char * (*open_file)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, size_t *data_len ); /* */
|
const char * (*open_file)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, size_t *data_len ); /* */
|
||||||
void (*init_lua)( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, void *lua_context ); /* */
|
void (*init_lua)( struct lh_ctx_t *ctx, const struct lh_con_t *conn, void *lua_context ); /* */
|
||||||
int (*http_error)( const struct lh_ctx_t *ctx, struct lh_con_t *, int status ); /* */
|
int (*http_error)( struct lh_ctx_t *ctx, struct lh_con_t *, int status ); /* */
|
||||||
void (*init_context)( const struct lh_ctx_t *ctx ); /* */
|
void (*init_context)( struct lh_ctx_t *ctx ); /* */
|
||||||
void (*init_thread)( const struct lh_ctx_t *ctx, int thread_type ); /* */
|
void (*init_thread)( struct lh_ctx_t *ctx, int thread_type ); /* */
|
||||||
void (*exit_context)( const struct lh_ctx_t *ctx ); /* */
|
void (*exit_context)( struct lh_ctx_t *ctx ); /* */
|
||||||
}; /* */
|
}; /* */
|
||||||
/************************************************************************************************/
|
/************************************************************************************************/
|
||||||
|
|
||||||
@@ -333,12 +333,12 @@ struct httplib_form_data_handler {
|
|||||||
void * user_data;
|
void * user_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*httplib_request_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
typedef int (*httplib_request_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
||||||
typedef int (*httplib_authorization_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
typedef int (*httplib_authorization_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
||||||
typedef int (*httplib_websocket_connect_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
typedef int (*httplib_websocket_connect_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
||||||
typedef void (*httplib_websocket_ready_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
typedef void (*httplib_websocket_ready_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
||||||
typedef int (*httplib_websocket_data_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int, char *buffer, size_t buflen, void *cbdata );
|
typedef int (*httplib_websocket_data_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, int, char *buffer, size_t buflen, void *cbdata );
|
||||||
typedef void (*httplib_websocket_close_handler)( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
typedef void (*httplib_websocket_close_handler)( struct lh_ctx_t *ctx, struct lh_con_t *conn, void *cbdata );
|
||||||
|
|
||||||
typedef LIBHTTP_THREAD_TYPE (LIBHTTP_THREAD_CALLING_CONV *httplib_thread_func_t)(void *arg);
|
typedef LIBHTTP_THREAD_TYPE (LIBHTTP_THREAD_CALLING_CONV *httplib_thread_func_t)(void *arg);
|
||||||
|
|
||||||
@@ -375,7 +375,7 @@ LIBHTTP_API struct lh_con_t * httplib_connect_client( struct lh_ctx_t *ctx, con
|
|||||||
LIBHTTP_API struct lh_con_t * httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options );
|
LIBHTTP_API struct lh_con_t * httplib_connect_client_secure( struct lh_ctx_t *ctx, const struct httplib_client_options *client_options );
|
||||||
LIBHTTP_API struct lh_con_t * httplib_connect_websocket_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data );
|
LIBHTTP_API struct lh_con_t * httplib_connect_websocket_client( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, const char *path, const char *origin, httplib_websocket_data_handler data_func, httplib_websocket_close_handler close_func, void *user_data );
|
||||||
LIBHTTP_API struct lh_ctx_t * httplib_create_client_context( const struct lh_clb_t *callbacks, const struct lh_opt_t *options );
|
LIBHTTP_API struct lh_ctx_t * httplib_create_client_context( const struct lh_clb_t *callbacks, const struct lh_opt_t *options );
|
||||||
LIBHTTP_API void httplib_cry( enum lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(4, 5);
|
LIBHTTP_API void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *conn, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(4, 5);
|
||||||
LIBHTTP_API void httplib_destroy_client_context( struct lh_ctx_t *ctx );
|
LIBHTTP_API void httplib_destroy_client_context( struct lh_ctx_t *ctx );
|
||||||
LIBHTTP_API struct lh_con_t * httplib_download( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, PRINTF_FORMAT_STRING(const char *request_fmt), ...) PRINTF_ARGS(5, 6);
|
LIBHTTP_API struct lh_con_t * httplib_download( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, PRINTF_FORMAT_STRING(const char *request_fmt), ...) PRINTF_ARGS(5, 6);
|
||||||
LIBHTTP_API char * httplib_error_string( int error_code, char *buf, size_t buf_len );
|
LIBHTTP_API char * httplib_error_string( int error_code, char *buf, size_t buf_len );
|
||||||
@@ -387,14 +387,14 @@ LIBHTTP_API const char * httplib_get_option( const struct lh_ctx_t *ctx, const
|
|||||||
LIBHTTP_API uint64_t httplib_get_random( void );
|
LIBHTTP_API uint64_t httplib_get_random( void );
|
||||||
LIBHTTP_API const struct lh_rqi_t * httplib_get_request_info( const struct lh_con_t *conn );
|
LIBHTTP_API const struct lh_rqi_t * httplib_get_request_info( const struct lh_con_t *conn );
|
||||||
LIBHTTP_API int httplib_get_response( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int timeout );
|
LIBHTTP_API int httplib_get_response( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int timeout );
|
||||||
LIBHTTP_API const char * httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code );
|
LIBHTTP_API const char * httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code );
|
||||||
LIBHTTP_API int httplib_get_server_ports( const struct lh_ctx_t *ctx, int size, struct lh_slp_t *ports );
|
LIBHTTP_API int httplib_get_server_ports( const struct lh_ctx_t *ctx, int size, struct lh_slp_t *ports );
|
||||||
LIBHTTP_API void * httplib_get_user_connection_data( const struct lh_con_t *conn );
|
LIBHTTP_API void * httplib_get_user_connection_data( const struct lh_con_t *conn );
|
||||||
LIBHTTP_API void * httplib_get_user_data( const struct lh_ctx_t *ctx );
|
LIBHTTP_API void * httplib_get_user_data( const struct lh_ctx_t *ctx );
|
||||||
LIBHTTP_API int httplib_get_var( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len );
|
LIBHTTP_API int httplib_get_var( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len );
|
||||||
LIBHTTP_API int httplib_get_var2( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len, size_t occurrence );
|
LIBHTTP_API int httplib_get_var2( const char *data, size_t data_len, const char *var_name, char *dst, size_t dst_len, size_t occurrence );
|
||||||
LIBHTTP_API struct tm * httplib_gmtime_r( const time_t *clock, struct tm *result );
|
LIBHTTP_API struct tm * httplib_gmtime_r( const time_t *clock, struct tm *result );
|
||||||
LIBHTTP_API int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh );
|
LIBHTTP_API int httplib_handle_form_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh );
|
||||||
LIBHTTP_API int httplib_kill( pid_t pid, int sig_num );
|
LIBHTTP_API int httplib_kill( pid_t pid, int sig_num );
|
||||||
LIBHTTP_API struct tm * httplib_localtime_r( const time_t *clock, struct tm *result );
|
LIBHTTP_API struct tm * httplib_localtime_r( const time_t *clock, struct tm *result );
|
||||||
LIBHTTP_API void httplib_lock_connection( struct lh_con_t *conn );
|
LIBHTTP_API void httplib_lock_connection( struct lh_con_t *conn );
|
||||||
@@ -425,7 +425,7 @@ LIBHTTP_API int httplib_pthread_setspecific( pthread_key_t key, void *value )
|
|||||||
LIBHTTP_API int httplib_read( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *buf, size_t len );
|
LIBHTTP_API int httplib_read( const struct lh_ctx_t *ctx, struct lh_con_t *conn, void *buf, size_t len );
|
||||||
LIBHTTP_API struct dirent * httplib_readdir( DIR *dir );
|
LIBHTTP_API struct dirent * httplib_readdir( DIR *dir );
|
||||||
LIBHTTP_API int httplib_remove( const char *path );
|
LIBHTTP_API int httplib_remove( const char *path );
|
||||||
LIBHTTP_API void httplib_send_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers );
|
LIBHTTP_API void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers );
|
||||||
LIBHTTP_API void httplib_set_alloc_callback_func( httplib_alloc_callback_func log_func );
|
LIBHTTP_API void httplib_set_alloc_callback_func( httplib_alloc_callback_func log_func );
|
||||||
LIBHTTP_API void httplib_set_auth_handler( struct lh_ctx_t *ctx, const char *uri, httplib_authorization_handler handler, void *cbdata );
|
LIBHTTP_API void httplib_set_auth_handler( struct lh_ctx_t *ctx, const char *uri, httplib_authorization_handler handler, void *cbdata );
|
||||||
LIBHTTP_API enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level );
|
LIBHTTP_API enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level );
|
||||||
@@ -435,7 +435,7 @@ LIBHTTP_API void httplib_set_websocket_handler( struct lh_ctx_t *ctx, const ch
|
|||||||
LIBHTTP_API struct lh_ctx_t * httplib_start( const struct lh_clb_t *callbacks, void *user_data, const struct lh_opt_t *options );
|
LIBHTTP_API struct lh_ctx_t * httplib_start( const struct lh_clb_t *callbacks, void *user_data, const struct lh_opt_t *options );
|
||||||
LIBHTTP_API int httplib_start_thread( httplib_thread_func_t func, void *param );
|
LIBHTTP_API int httplib_start_thread( httplib_thread_func_t func, void *param );
|
||||||
LIBHTTP_API void httplib_stop( struct lh_ctx_t *ctx );
|
LIBHTTP_API void httplib_stop( struct lh_ctx_t *ctx );
|
||||||
LIBHTTP_API int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
LIBHTTP_API int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
LIBHTTP_API int httplib_strcasecmp( const char *s1, const char *s2 );
|
LIBHTTP_API int httplib_strcasecmp( const char *s1, const char *s2 );
|
||||||
LIBHTTP_API const char * httplib_strcasestr( const char *big_str, const char *small_str );
|
LIBHTTP_API const char * httplib_strcasestr( const char *big_str, const char *small_str );
|
||||||
LIBHTTP_API char * httplib_strdup( const char *str );
|
LIBHTTP_API char * httplib_strdup( const char *str );
|
||||||
@@ -449,7 +449,7 @@ LIBHTTP_API void httplib_unlock_context( struct lh_ctx_t *ctx );
|
|||||||
LIBHTTP_API int httplib_url_decode( const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded );
|
LIBHTTP_API int httplib_url_decode( const char *src, int src_len, char *dst, int dst_len, int is_form_url_encoded );
|
||||||
LIBHTTP_API int httplib_url_encode( const char *src, char *dst, size_t dst_len );
|
LIBHTTP_API int httplib_url_encode( const char *src, char *dst, size_t dst_len );
|
||||||
LIBHTTP_API const char * httplib_version( void );
|
LIBHTTP_API const char * httplib_version( void );
|
||||||
LIBHTTP_API int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len );
|
LIBHTTP_API int httplib_websocket_client_write( struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len );
|
||||||
LIBHTTP_API int httplib_websocket_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len );
|
LIBHTTP_API int httplib_websocket_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t data_len );
|
||||||
LIBHTTP_API int httplib_write( const struct lh_ctx_t *ctx, struct lh_con_t * conn, const void *buf, size_t len );
|
LIBHTTP_API int httplib_write( const struct lh_ctx_t *ctx, struct lh_con_t * conn, const void *buf, size_t len );
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... );
|
* void XX_httplib_addenv( struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_addenv() adds one item to the environment before
|
* The function XX_httplib_addenv() adds one item to the environment before
|
||||||
* a CGI script is called. The environment variable has the form
|
* a CGI script is called. The environment variable has the form
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
#if !defined(NO_CGI)
|
#if !defined(NO_CGI)
|
||||||
|
|
||||||
void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ) {
|
void XX_httplib_addenv( struct lh_ctx_t *ctx, struct cgi_environment *env, const char *fmt, ... ) {
|
||||||
|
|
||||||
size_t n;
|
size_t n;
|
||||||
size_t space;
|
size_t space;
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
* bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_authorize() authorizes agains the open passwords
|
* The function XX_httplib_authorize() authorizes agains the open passwords
|
||||||
* file. It returns 1 if authorized.
|
* file. It returns 1 if authorized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) {
|
bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) {
|
||||||
|
|
||||||
struct read_auth_file_struct workdata;
|
struct read_auth_file_struct workdata;
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/* Return 1 if request is authorised, 0 otherwise. */
|
/* Return 1 if request is authorised, 0 otherwise. */
|
||||||
bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
bool XX_httplib_check_authorization( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
char fname[PATH_MAX];
|
char fname[PATH_MAX];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
* void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_close_socket_gracefully() closes a socket in a
|
* The function XX_httplib_close_socket_gracefully() closes a socket in a
|
||||||
* graceful way.
|
* graceful way.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
|
@@ -29,13 +29,13 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep );
|
* void XX_httplib_construct_etag( struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_construct_etag() is used to construct an etag which
|
* The function XX_httplib_construct_etag() is used to construct an etag which
|
||||||
* can be used to identify a file on a specific moment.
|
* can be used to identify a file on a specific moment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ) {
|
void XX_httplib_construct_etag( struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep ) {
|
||||||
|
|
||||||
if ( filep != NULL && buf != NULL && buf_len > 0 ) {
|
if ( filep != NULL && buf != NULL && buf_len > 0 ) {
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
struct lh_ctx_t *httplib_create_client_context( const struct lh_clb_t *callbacks, const struct lh_opt_t *options ) {
|
struct lh_ctx_t *httplib_create_client_context( const struct lh_clb_t *callbacks, const struct lh_opt_t *options ) {
|
||||||
|
|
||||||
struct lh_ctx_t *ctx;
|
struct lh_ctx_t *ctx;
|
||||||
void (*exit_callback)(const struct lh_ctx_t *ctx);
|
void (*exit_callback)(struct lh_ctx_t *ctx);
|
||||||
|
|
||||||
exit_callback = NULL;
|
exit_callback = NULL;
|
||||||
ctx = httplib_calloc( 1, sizeof(struct lh_ctx_t) );
|
ctx = httplib_calloc( 1, sizeof(struct lh_ctx_t) );
|
||||||
|
@@ -26,14 +26,14 @@
|
|||||||
#include "httplib_ssl.h"
|
#include "httplib_ssl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void httplib_cry( enum lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... );
|
* void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... );
|
||||||
*
|
*
|
||||||
* The function httplib_cry() prints a formatted error message to the opened
|
* The function httplib_cry() prints a formatted error message to the opened
|
||||||
* error log stream. It first tries to use a user supplied error handler. If
|
* error log stream. It first tries to use a user supplied error handler. If
|
||||||
* that doesn't work, the alternative is to write to an error log file.
|
* that doesn't work, the alternative is to write to an error log file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void httplib_cry( enum lh_dbg_t debug_level, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... ) {
|
void httplib_cry( enum lh_dbg_t debug_level, struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... ) {
|
||||||
|
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
char src_addr[IP_ADDR_STR_LEN];
|
char src_addr[IP_ADDR_STR_LEN];
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
* void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_delete_file() deletes a file after a request over a
|
* The function XX_httplib_delete_file() deletes a file after a request over a
|
||||||
* connection.
|
* connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
struct de de;
|
struct de de;
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
void XX_httplib_dir_scan_callback( const struct lh_ctx_t *ctx, struct de *de, void *data ) {
|
void XX_httplib_dir_scan_callback( struct lh_ctx_t *ctx, struct de *de, void *data ) {
|
||||||
|
|
||||||
struct dir_scan_data *dsd;
|
struct dir_scan_data *dsd;
|
||||||
struct de* old_entries;
|
struct de* old_entries;
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ) {
|
void XX_httplib_fclose_on_exec( struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn ) {
|
||||||
|
|
||||||
if ( ctx == NULL || filep == NULL || filep->fp == NULL ) return;
|
if ( ctx == NULL || filep == NULL || filep->fp == NULL ) return;
|
||||||
|
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep );
|
* bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_fopen() can be used to open a file which is either
|
* The function XX_httplib_fopen() can be used to open a file which is either
|
||||||
* in memory or on the disk. The path is in UTF-8 and therefore needs
|
* in memory or on the disk. The path is in UTF-8 and therefore needs
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
* of the same structure (bad cohesion).
|
* of the same structure (bad cohesion).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ) {
|
bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep ) {
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl );
|
* bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_forward_body_data() forwards body data to the
|
* The function XX_httplib_forward_body_data() forwards body data to the
|
||||||
* client. The function returns true if successful, and false otherwise.
|
* client. The function returns true if successful, and false otherwise.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ) {
|
bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl ) {
|
||||||
|
|
||||||
const char *expect;
|
const char *expect;
|
||||||
const char *body;
|
const char *body;
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* const char *httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code );
|
* const char *httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code );
|
||||||
*
|
*
|
||||||
* The function httplib_get_response_code_text() returns a text associated with an
|
* The function httplib_get_response_code_text() returns a text associated with an
|
||||||
* HTTP response code.
|
* HTTP response code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const char *httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ) {
|
const char *httplib_get_response_code_text( struct lh_ctx_t *ctx, struct lh_con_t *conn, int response_code ) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See IANA HTTP status code assignment:
|
* See IANA HTTP status code assignment:
|
||||||
|
@@ -29,12 +29,12 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err );
|
* bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_getreq() processes a request from a remote client.
|
* The function XX_httplib_getreq() processes a request from a remote client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ) {
|
bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err ) {
|
||||||
|
|
||||||
const char *cl;
|
const char *cl;
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog );
|
* void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_handle_cgi_request() handles a request for a CGI
|
* The function XX_httplib_handle_cgi_request() handles a request for a CGI
|
||||||
* resource.
|
* resource.
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#if !defined(NO_CGI)
|
#if !defined(NO_CGI)
|
||||||
|
|
||||||
void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ) {
|
void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog ) {
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
size_t buflen;
|
size_t buflen;
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
void XX_httplib_handle_directory_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) {
|
void XX_httplib_handle_directory_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) {
|
||||||
|
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int sort_direction;
|
int sort_direction;
|
||||||
|
@@ -28,14 +28,14 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file );
|
* void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_handle_file_based_request() handles a request which
|
* The function XX_httplib_handle_file_based_request() handles a request which
|
||||||
* involves a file. This can either be a CGI request, an SSI request of a
|
* involves a file. This can either be a CGI request, an SSI request of a
|
||||||
* request for a static file.
|
* request for a static file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file ) {
|
void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *file ) {
|
||||||
|
|
||||||
#if !defined(NO_CGI)
|
#if !defined(NO_CGI)
|
||||||
const char *cgi_ext;
|
const char *cgi_ext;
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *key, size_t key_len, const char *filename, size_t filename_len, char *path, size_t path_len, struct httplib_form_data_handler *fdh ) {
|
static int url_encoded_field_found( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *key, size_t key_len, const char *filename, size_t filename_len, char *path, size_t path_len, struct httplib_form_data_handler *fdh ) {
|
||||||
|
|
||||||
char key_dec[1024];
|
char key_dec[1024];
|
||||||
char filename_dec[1024];
|
char filename_dec[1024];
|
||||||
@@ -77,7 +77,7 @@ static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct lh_
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int url_encoded_field_get( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *key, size_t key_len, const char *value, size_t value_len, struct httplib_form_data_handler *fdh ) {
|
static int url_encoded_field_get( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *key, size_t key_len, const char *value, size_t value_len, struct httplib_form_data_handler *fdh ) {
|
||||||
|
|
||||||
char key_dec[1024];
|
char key_dec[1024];
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ static const char * search_boundary(const char *buf, size_t buf_len, const char
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh ) {
|
int httplib_handle_form_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct httplib_form_data_handler *fdh ) {
|
||||||
|
|
||||||
const char *content_type;
|
const char *content_type;
|
||||||
char path[512];
|
char path[512];
|
||||||
|
@@ -29,14 +29,14 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
* void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_handle_not_modified_static_file_request() is used to
|
* The function XX_httplib_handle_not_modified_static_file_request() is used to
|
||||||
* send a 304 response to a client to indicate that the requested resource has
|
* send a 304 response to a client to indicate that the requested resource has
|
||||||
* not been changed.
|
* not been changed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) {
|
void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep ) {
|
||||||
|
|
||||||
char date[64];
|
char date[64];
|
||||||
char lm[64];
|
char lm[64];
|
||||||
|
@@ -30,13 +30,13 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* static void print_props( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep );
|
* static void print_props( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function print_props() writes the PROPFIND properties for a collection
|
* The function print_props() writes the PROPFIND properties for a collection
|
||||||
* event.
|
* event.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void print_props( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep ) {
|
static void print_props( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *uri, struct file *filep ) {
|
||||||
|
|
||||||
char mtime[64];
|
char mtime[64];
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ static void print_props( const struct lh_ctx_t *ctx, struct lh_con_t *conn, cons
|
|||||||
} /* print_props */
|
} /* print_props */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void *data );
|
* static void print_dav_dir_entry( struct lh_ctx_t *ctx, struct de *de, void *data );
|
||||||
*
|
*
|
||||||
* The function print_dav_dir_entry() is used to send the properties of a
|
* The function print_dav_dir_entry() is used to send the properties of a
|
||||||
* webdav directory to the remote client.
|
* webdav directory to the remote client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void *data ) {
|
static void print_dav_dir_entry( struct lh_ctx_t *ctx, struct de *de, void *data ) {
|
||||||
|
|
||||||
char href[PATH_MAX];
|
char href[PATH_MAX];
|
||||||
char href_encoded[PATH_MAX * 3 /* worst case */];
|
char href_encoded[PATH_MAX * 3 /* worst case */];
|
||||||
@@ -91,12 +91,12 @@ static void print_dav_dir_entry( const struct lh_ctx_t *ctx, struct de *de, void
|
|||||||
} /* print_dav_dir_entry */
|
} /* print_dav_dir_entry */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_handle_propfind( const stuct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
* void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httlib_handle_propfind() handles a propfind request.
|
* The function XX_httlib_handle_propfind() handles a propfind request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
const char *depth;
|
const char *depth;
|
||||||
char date[64];
|
char date[64];
|
||||||
|
@@ -36,7 +36,7 @@
|
|||||||
* request for a static file.
|
* request for a static file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_handle_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ) {
|
void XX_httplib_handle_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers ) {
|
||||||
|
|
||||||
char date[64];
|
char date[64];
|
||||||
char lm[64];
|
char lm[64];
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
* request on a connection.
|
* request on a connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_handle_websocket_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ) {
|
void XX_httplib_handle_websocket_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData ) {
|
||||||
|
|
||||||
const char *websock_key;
|
const char *websock_key;
|
||||||
const char *version;
|
const char *version;
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
* The function XX_httplib_interpret_uri() interprets an URI and decides what
|
* The function XX_httplib_interpret_uri() interprets an URI and decides what
|
||||||
* type of request is involved. The function takes the following parameters:
|
* type of request is involved. The function takes the following parameters:
|
||||||
*
|
*
|
||||||
|
* ctx: in: The context in which to communicate
|
||||||
* conn: in: The request (must be valid)
|
* conn: in: The request (must be valid)
|
||||||
* filename: out: Filename
|
* filename: out: Filename
|
||||||
* filename_buf_len: in: Size of the filename buffer
|
* filename_buf_len: in: Size of the filename buffer
|
||||||
@@ -44,7 +45,7 @@
|
|||||||
* is_put_or_delete_request: out: put/delete file?
|
* is_put_or_delete_request: out: put/delete file?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ) {
|
void XX_httplib_interpret_uri( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request ) {
|
||||||
|
|
||||||
/* TODO (high): Restructure this function */
|
/* TODO (high): Restructure this function */
|
||||||
|
|
||||||
|
@@ -25,14 +25,14 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
* bool XX_httplib_is_authorized_for_put( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_is_authorized_for_put() returns true, if the client
|
* The function XX_httplib_is_authorized_for_put() returns true, if the client
|
||||||
* on the connection has authorization to use put and equivalent methods to
|
* on the connection has authorization to use put and equivalent methods to
|
||||||
* write information to the server.
|
* write information to the server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
bool XX_httplib_is_authorized_for_put( struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
||||||
|
|
||||||
struct file file = STRUCT_FILE_INITIALIZER;
|
struct file file = STRUCT_FILE_INITIALIZER;
|
||||||
const char *passfile;
|
const char *passfile;
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep );
|
* bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_is_file_in_memory() returns true, if a file defined
|
* The function XX_httplib_is_file_in_memory() returns true, if a file defined
|
||||||
* by a specific path is located in memory.
|
* by a specific path is located in memory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep ) {
|
bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
size_t size;
|
size_t size;
|
||||||
|
|
||||||
|
@@ -28,14 +28,14 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep );
|
* bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_is_not_modified() returns true, if a resource has
|
* The function XX_httplib_is_not_modified() returns true, if a resource has
|
||||||
* not been modified sinze a given datetime and a 304 response should therefore
|
* not been modified sinze a given datetime and a 304 response should therefore
|
||||||
* be sufficient.
|
* be sufficient.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ) {
|
bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep ) {
|
||||||
|
|
||||||
char etag[64];
|
char etag[64];
|
||||||
const char *ims = httplib_get_header( conn, "If-Modified-Since" );
|
const char *ims = httplib_get_header( conn, "If-Modified-Since" );
|
||||||
|
@@ -32,12 +32,12 @@
|
|||||||
static const char *header_val( const struct lh_con_t *conn, const char *header );
|
static const char *header_val( const struct lh_con_t *conn, const char *header );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
* void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_log_access() logs an access of a client.
|
* The function XX_httplib_log_access() logs an access of a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct lh_con_t *conn ) {
|
void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *conn ) {
|
||||||
|
|
||||||
const struct lh_rqi_t *ri;
|
const struct lh_rqi_t *ri;
|
||||||
struct file fi;
|
struct file fi;
|
||||||
|
@@ -788,27 +788,27 @@ void SHA1Update( SHA1_CTX *context, const unsigned char *data, uint32_t len );
|
|||||||
|
|
||||||
struct lh_ctx_t * XX_httplib_abort_start( struct lh_ctx_t *ctx, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
|
struct lh_ctx_t * XX_httplib_abort_start( struct lh_ctx_t *ctx, PRINTF_FORMAT_STRING(const char *fmt), ...) PRINTF_ARGS(2, 3);
|
||||||
void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_ctx_t *ctx );
|
void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_ctx_t *ctx );
|
||||||
bool XX_httplib_authorize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
bool XX_httplib_authorize( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
||||||
const char * XX_httplib_builtin_mime_ext( int index );
|
const char * XX_httplib_builtin_mime_ext( int index );
|
||||||
const char * XX_httplib_builtin_mime_type( int index );
|
const char * XX_httplib_builtin_mime_type( int index );
|
||||||
int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip );
|
int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip );
|
||||||
bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
bool XX_httplib_check_authorization( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
bool XX_httplib_check_password( const char *method, const char *ha1, const char *uri, const char *nonce, const char *nc, const char *cnonce, const char *qop, const char *response );
|
bool XX_httplib_check_password( const char *method, const char *ha1, const char *uri, const char *nonce, const char *nc, const char *cnonce, const char *qop, const char *response );
|
||||||
void XX_httplib_close_all_listening_sockets( struct lh_ctx_t *ctx );
|
void XX_httplib_close_all_listening_sockets( struct lh_ctx_t *ctx );
|
||||||
void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_close_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_close_socket_gracefully( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
int WINCDECL XX_httplib_compare_dir_entries( const void *p1, const void *p2 );
|
int WINCDECL XX_httplib_compare_dir_entries( const void *p1, const void *p2 );
|
||||||
bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa );
|
bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port, int use_ssl, SOCKET *sock, union usa *sa );
|
||||||
void XX_httplib_construct_etag( const struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep );
|
void XX_httplib_construct_etag( struct lh_ctx_t *ctx, char *buf, size_t buf_len, const struct file *filep );
|
||||||
int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index );
|
int XX_httplib_consume_socket( struct lh_ctx_t *ctx, struct socket *sp, int thread_index );
|
||||||
void XX_httplib_delete_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
void XX_httplib_delete_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
void XX_httplib_dir_scan_callback( const struct lh_ctx_t *ctx, struct de *de, void *data );
|
void XX_httplib_dir_scan_callback( struct lh_ctx_t *ctx, struct de *de, void *data );
|
||||||
void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_discard_unread_request_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
int XX_httplib_fclose( struct file *filep );
|
int XX_httplib_fclose( struct file *filep );
|
||||||
void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn );
|
void XX_httplib_fclose_on_exec( struct lh_ctx_t *ctx, struct file *filep, struct lh_con_t *conn );
|
||||||
const char * XX_httplib_fgets( char *buf, size_t size, struct file *filep, char **p );
|
const char * XX_httplib_fgets( char *buf, size_t size, struct file *filep, char **p );
|
||||||
bool XX_httplib_fopen( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep );
|
bool XX_httplib_fopen( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, const char *mode, struct file *filep );
|
||||||
bool XX_httplib_forward_body_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl );
|
bool XX_httplib_forward_body_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, FILE *fp, SOCKET sock, SSL *ssl );
|
||||||
void XX_httplib_free_config_options( struct lh_ctx_t *ctx );
|
void XX_httplib_free_config_options( struct lh_ctx_t *ctx );
|
||||||
void XX_httplib_free_context( struct lh_ctx_t *ctx );
|
void XX_httplib_free_context( struct lh_ctx_t *ctx );
|
||||||
const char * XX_httplib_get_header( const struct lh_rqi_t *ri, const char *name );
|
const char * XX_httplib_get_header( const struct lh_rqi_t *ri, const char *name );
|
||||||
@@ -819,35 +819,35 @@ int XX_httplib_get_request_handler( struct lh_ctx_t *ctx, struct lh_con_t *con
|
|||||||
int XX_httplib_get_request_len( const char *buf, int buflen );
|
int XX_httplib_get_request_len( const char *buf, int buflen );
|
||||||
void XX_httplib_get_system_name( char **sysName );
|
void XX_httplib_get_system_name( char **sysName );
|
||||||
enum uri_type_t XX_httplib_get_uri_type( const char *uri );
|
enum uri_type_t XX_httplib_get_uri_type( const char *uri );
|
||||||
bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err );
|
bool XX_httplib_getreq( struct lh_ctx_t *ctx, struct lh_con_t *conn, int *err );
|
||||||
void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog );
|
void XX_httplib_handle_cgi_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog );
|
||||||
void XX_httplib_handle_directory_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
void XX_httplib_handle_directory_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
||||||
void XX_httplib_handle_file_based_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
void XX_httplib_handle_file_based_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
void XX_httplib_handle_not_modified_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
void XX_httplib_handle_not_modified_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep );
|
||||||
void XX_httplib_handle_propfind( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
void XX_httplib_handle_propfind( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
void XX_httplib_handle_ssi_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
void XX_httplib_handle_static_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers );
|
void XX_httplib_handle_static_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, const char *mime_type, const char *additional_headers );
|
||||||
void XX_httplib_handle_websocket_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData );
|
void XX_httplib_handle_websocket_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, int is_callback_resource, httplib_websocket_connect_handler ws_connect_handler, httplib_websocket_ready_handler ws_ready_handler, httplib_websocket_data_handler ws_data_handler, httplib_websocket_close_handler ws_close_handler, void *cbData );
|
||||||
bool XX_httplib_header_has_option( const char *header, const char *option );
|
bool XX_httplib_header_has_option( const char *header, const char *option );
|
||||||
bool XX_httplib_init_options( struct lh_ctx_t *ctx );
|
bool XX_httplib_init_options( struct lh_ctx_t *ctx );
|
||||||
void XX_httplib_interpret_uri( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request );
|
void XX_httplib_interpret_uri( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *filename, size_t filename_buf_len, struct file *filep, bool *is_found, bool *is_script_resource, bool *is_websocket_request, bool *is_put_or_delete_request );
|
||||||
bool XX_httplib_is_authorized_for_put( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
bool XX_httplib_is_authorized_for_put( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
bool XX_httplib_is_file_in_memory( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep );
|
bool XX_httplib_is_file_in_memory( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
bool XX_httplib_is_file_opened( const struct file *filep );
|
bool XX_httplib_is_file_opened( const struct file *filep );
|
||||||
bool XX_httplib_is_not_modified( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep );
|
bool XX_httplib_is_not_modified( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const struct file *filep );
|
||||||
bool XX_httplib_is_put_or_delete_method( const struct lh_con_t *conn );
|
bool XX_httplib_is_put_or_delete_method( const struct lh_con_t *conn );
|
||||||
bool XX_httplib_is_valid_http_method( const char *method );
|
bool XX_httplib_is_valid_http_method( const char *method );
|
||||||
int XX_httplib_is_valid_port( unsigned long port );
|
int XX_httplib_is_valid_port( unsigned long port );
|
||||||
bool XX_httplib_is_websocket_protocol( const struct lh_con_t *conn );
|
bool XX_httplib_is_websocket_protocol( const struct lh_con_t *conn );
|
||||||
void * XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ssl_func *sw );
|
void * XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ssl_func *sw );
|
||||||
void XX_httplib_log_access( const struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
void XX_httplib_log_access( struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
||||||
LIBHTTP_THREAD XX_httplib_master_thread( void *thread_func_param );
|
LIBHTTP_THREAD XX_httplib_master_thread( void *thread_func_param );
|
||||||
int XX_httplib_match_prefix(const char *pattern, size_t pattern_len, const char *str);
|
int XX_httplib_match_prefix(const char *pattern, size_t pattern_len, const char *str);
|
||||||
void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
bool XX_httplib_must_hide_file( const struct lh_ctx_t *ctx, const char *path );
|
bool XX_httplib_must_hide_file( const struct lh_ctx_t *ctx, const char *path );
|
||||||
const char * XX_httplib_next_option( const char *list, struct vec *val, struct vec *eq_val );
|
const char * XX_httplib_next_option( const char *list, struct vec *val, struct vec *eq_val );
|
||||||
void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
void XX_httplib_open_auth_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
bool XX_httplib_option_value_to_bool( const char *value, bool *config );
|
bool XX_httplib_option_value_to_bool( const char *value, bool *config );
|
||||||
bool XX_httplib_option_value_to_int( const char *value, int *config );
|
bool XX_httplib_option_value_to_int( const char *value, int *config );
|
||||||
int XX_httplib_parse_auth_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *buf, size_t buf_size, struct ah *ah );
|
int XX_httplib_parse_auth_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *buf, size_t buf_size, struct ah *ah );
|
||||||
@@ -857,33 +857,33 @@ int XX_httplib_parse_http_message( char *buf, int len, struct lh_rqi_t *ri );
|
|||||||
int XX_httplib_parse_net( const char *spec, uint32_t *net, uint32_t *mask );
|
int XX_httplib_parse_net( const char *spec, uint32_t *net, uint32_t *mask );
|
||||||
int XX_httplib_parse_range_header( const char *header, int64_t *a, int64_t *b );
|
int XX_httplib_parse_range_header( const char *header, int64_t *a, int64_t *b );
|
||||||
void XX_httplib_path_to_unicode( const char *path, wchar_t *wbuf, size_t wbuf_len );
|
void XX_httplib_path_to_unicode( const char *path, wchar_t *wbuf, size_t wbuf_len );
|
||||||
void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env );
|
void XX_httplib_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env );
|
||||||
void XX_httplib_print_dir_entry( const struct lh_ctx_t *ctx, struct de *de );
|
void XX_httplib_print_dir_entry( struct lh_ctx_t *ctx, struct de *de );
|
||||||
void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct lh_opt_t *options );
|
bool XX_httplib_process_options( struct lh_ctx_t *ctx, const struct lh_opt_t *options );
|
||||||
void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp );
|
void XX_httplib_produce_socket( struct lh_ctx_t *ctx, const struct socket *sp );
|
||||||
int XX_httplib_pull( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int len, double timeout );
|
int XX_httplib_pull( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int len, double timeout );
|
||||||
int XX_httplib_pull_all( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int len );
|
int XX_httplib_pull_all( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int len );
|
||||||
int64_t XX_httplib_push_all( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len );
|
int64_t XX_httplib_push_all( const struct lh_ctx_t *ctx, FILE *fp, SOCKET sock, SSL *ssl, const char *buf, int64_t len );
|
||||||
int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
int XX_httplib_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata );
|
bool XX_httplib_read_auth_file( struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata );
|
||||||
int XX_httplib_read_request( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int bufsiz, int *nread );
|
int XX_httplib_read_request( const struct lh_ctx_t *ctx, FILE *fp, struct lh_con_t *conn, char *buf, int bufsiz, int *nread );
|
||||||
void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data );
|
void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data );
|
||||||
void XX_httplib_redirect_to_https_port( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int ssl_index );
|
void XX_httplib_redirect_to_https_port( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int ssl_index );
|
||||||
int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path );
|
void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path );
|
||||||
int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
||||||
void XX_httplib_remove_double_dots_and_double_slashes( char *s );
|
void XX_httplib_remove_double_dots_and_double_slashes( char *s );
|
||||||
void XX_httplib_reset_per_request_attributes( struct lh_con_t *conn );
|
void XX_httplib_reset_per_request_attributes( struct lh_con_t *conn );
|
||||||
int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) );
|
int XX_httplib_scan_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(struct lh_ctx_t *ctx, struct de *, void *) );
|
||||||
void XX_httplib_send_authorization_request( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_send_authorization_request( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len );
|
void XX_httplib_send_file_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len );
|
||||||
void XX_httplib_send_http_error( const struct lh_ctx_t *ctx, struct lh_con_t *, int, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(4, 5);
|
void XX_httplib_send_http_error( struct lh_ctx_t *ctx, struct lh_con_t *, int, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(4, 5);
|
||||||
int XX_httplib_send_no_cache_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
int XX_httplib_send_no_cache_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
void XX_httplib_send_options( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
int XX_httplib_send_static_cache_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
int XX_httplib_send_static_cache_header( const struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key );
|
int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key );
|
||||||
int XX_httplib_set_acl_option( struct lh_ctx_t *ctx );
|
int XX_httplib_set_acl_option( struct lh_ctx_t *ctx );
|
||||||
void XX_httplib_set_close_on_exec( SOCKET sock );
|
void XX_httplib_set_close_on_exec( SOCKET sock );
|
||||||
bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx );
|
bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx );
|
||||||
@@ -892,7 +892,7 @@ int XX_httplib_set_non_blocking_mode( SOCKET sock );
|
|||||||
int XX_httplib_set_ports_option( struct lh_ctx_t *ctx );
|
int XX_httplib_set_ports_option( struct lh_ctx_t *ctx );
|
||||||
int XX_httplib_set_sock_timeout( SOCKET sock, int milliseconds );
|
int XX_httplib_set_sock_timeout( SOCKET sock, int milliseconds );
|
||||||
int XX_httplib_set_tcp_nodelay( SOCKET sock, bool nodelay_on );
|
int XX_httplib_set_tcp_nodelay( SOCKET sock, bool nodelay_on );
|
||||||
void XX_httplib_set_thread_name( const struct lh_ctx_t *ctx, const char *name );
|
void XX_httplib_set_thread_name( struct lh_ctx_t *ctx, const char *name );
|
||||||
int XX_httplib_set_throttle( const char *spec, uint32_t remote_ip, const char *uri );
|
int XX_httplib_set_throttle( const char *spec, uint32_t remote_ip, const char *uri );
|
||||||
bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx );
|
bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx );
|
||||||
bool XX_httplib_should_decode_url( const struct lh_ctx_t *ctx );
|
bool XX_httplib_should_decode_url( const struct lh_ctx_t *ctx );
|
||||||
@@ -900,10 +900,10 @@ bool XX_httplib_should_keep_alive( const struct lh_ctx_t *ctx, const struct lh
|
|||||||
char * XX_httplib_skip( char **buf, const char *delimiters );
|
char * XX_httplib_skip( char **buf, const char *delimiters );
|
||||||
char * XX_httplib_skip_quoted( char **buf, const char *delimiters, const char *whitespace, char quotechar );
|
char * XX_httplib_skip_quoted( char **buf, const char *delimiters, const char *whitespace, char quotechar );
|
||||||
void XX_httplib_sockaddr_to_string(char *buf, size_t len, const union usa *usa );
|
void XX_httplib_sockaddr_to_string(char *buf, size_t len, const union usa *usa );
|
||||||
pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir );
|
pid_t XX_httplib_spawn_process( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir );
|
||||||
int XX_httplib_start_thread_with_id( httplib_thread_func_t func, void *param, pthread_t *threadidptr );
|
int XX_httplib_start_thread_with_id( httplib_thread_func_t func, void *param, pthread_t *threadidptr );
|
||||||
int XX_httplib_stat( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep );
|
||||||
int XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep );
|
int XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep );
|
||||||
const char * XX_httplib_suggest_connection_header( const struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
const char * XX_httplib_suggest_connection_header( const struct lh_ctx_t *ctx, const struct lh_con_t *conn );
|
||||||
LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data );
|
LIBHTTP_THREAD XX_httplib_websocket_client_thread( void *data );
|
||||||
int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key );
|
int XX_httplib_websocket_write_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen, uint32_t masking_key );
|
||||||
|
@@ -29,14 +29,14 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
* void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_mkcol() handles a MKCOL command from a remote
|
* The function XX_httplib_mkcol() handles a MKCOL command from a remote
|
||||||
* client. The MKCOL method is used to create a new collection resource at the
|
* client. The MKCOL method is used to create a new collection resource at the
|
||||||
* location specificied by the request URI.
|
* location specificied by the request URI.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
void XX_httplib_mkcol( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
int rc;
|
int rc;
|
||||||
int body_len;
|
int body_len;
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
* or search for .htpasswd in the requested directory.
|
* or search for .htpasswd in the requested directory.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
void XX_httplib_open_auth_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
char name[PATH_MAX];
|
char name[PATH_MAX];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -31,7 +31,7 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env );
|
* void XX_httplib_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_prepare_cgi_environment() is used to prepare all
|
* The function XX_httplib_prepare_cgi_environment() is used to prepare all
|
||||||
* environment variables before a CGI script is called.
|
* environment variables before a CGI script is called.
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
#if !defined(NO_CGI)
|
#if !defined(NO_CGI)
|
||||||
|
|
||||||
void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env ) {
|
void XX_httplib_prepare_cgi_environment( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, struct cgi_environment *env ) {
|
||||||
|
|
||||||
const char *s;
|
const char *s;
|
||||||
struct vec var_vec;
|
struct vec var_vec;
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
void XX_httplib_print_dir_entry( const struct lh_ctx_t *ctx, struct de *de ) {
|
void XX_httplib_print_dir_entry( struct lh_ctx_t *ctx, struct de *de ) {
|
||||||
|
|
||||||
char size[64];
|
char size[64];
|
||||||
char mod[64];
|
char mod[64];
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
* int XX_httplib_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_put_dir() creates a directory mentioned in a PUT
|
* The function XX_httplib_put_dir() creates a directory mentioned in a PUT
|
||||||
* request including all intermediate subdirectories. The following values can
|
* request including all intermediate subdirectories. The following values can
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
* Return -2 if path can not be created.
|
* Return -2 if path can not be created.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int XX_httplib_put_dir( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
int XX_httplib_put_dir( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
const char *s;
|
const char *s;
|
||||||
|
@@ -29,13 +29,13 @@
|
|||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
* void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_put_file() processes a file PUT request coming from
|
* The function XX_httplib_put_file() processes a file PUT request coming from
|
||||||
* a remote client.
|
* a remote client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_put_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
void XX_httplib_put_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
struct file file = STRUCT_FILE_INITIALIZER;
|
struct file file = STRUCT_FILE_INITIALIZER;
|
||||||
const char *range;
|
const char *range;
|
||||||
|
@@ -28,14 +28,14 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata );
|
* bool XX_httplib_read_auth_file( struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata );
|
||||||
*
|
*
|
||||||
* The function XX_httpib_read_auth_file() loops over the password file to
|
* The function XX_httpib_read_auth_file() loops over the password file to
|
||||||
* read its contents. Include statements are honored which lets the routine
|
* read its contents. Include statements are honored which lets the routine
|
||||||
* also open and scan child files.
|
* also open and scan child files.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ) {
|
bool XX_httplib_read_auth_file( struct lh_ctx_t *ctx, struct file *filep, struct read_auth_file_struct *workdata ) {
|
||||||
|
|
||||||
int is_authorized;
|
int is_authorized;
|
||||||
struct file fp;
|
struct file fp;
|
||||||
|
@@ -28,12 +28,12 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *calback_data );
|
* void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *calback_data );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_read_websocket() reads from a websocket connection.
|
* The function XX_httplib_read_websocket() reads from a websocket connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ) {
|
void XX_httplib_read_websocket( struct lh_ctx_t *ctx, struct lh_con_t *conn, httplib_websocket_data_handler ws_data_handler, void *callback_data ) {
|
||||||
|
|
||||||
/* Pointer to the beginning of the portion of the incoming websocket
|
/* Pointer to the beginning of the portion of the incoming websocket
|
||||||
* message queue.
|
* message queue.
|
||||||
|
@@ -33,7 +33,7 @@ static volatile int reload_lock = 0;
|
|||||||
static long int data_check = 0;
|
static long int data_check = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_refresh_trust( struct lh_con_t *conn );
|
* int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *conn );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_refresh_trust() is used to reload a certificate if
|
* The function XX_httplib_refresh_trust() is used to reload a certificate if
|
||||||
* it only has a short trust span.
|
* it only has a short trust span.
|
||||||
@@ -41,7 +41,7 @@ static long int data_check = 0;
|
|||||||
|
|
||||||
#if !defined(NO_SSL)
|
#if !defined(NO_SSL)
|
||||||
|
|
||||||
int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
int XX_httplib_refresh_trust( struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
||||||
|
|
||||||
volatile int *p_reload_lock;
|
volatile int *p_reload_lock;
|
||||||
struct stat cert_buf;
|
struct stat cert_buf;
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path );
|
* void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_remove_bad_file() removes an invalid file and throws
|
* The function XX_httplib_remove_bad_file() removes an invalid file and throws
|
||||||
* an error message if this does not succeed.
|
* an error message if this does not succeed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ) {
|
void XX_httplib_remove_bad_file( struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
int r = httplib_remove( path );
|
int r = httplib_remove( path );
|
||||||
|
|
||||||
|
@@ -29,13 +29,13 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
* int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_remove_directory() removes recursively a directory
|
* The function XX_httplib_remove_directory() removes recursively a directory
|
||||||
* tree.
|
* tree.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) {
|
int XX_httplib_remove_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir ) {
|
||||||
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(const struct lh_ctx_t *ctx, struct de *, void *) ) {
|
int XX_httplib_scan_directory( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *dir, void *data, void (*cb)(struct lh_ctx_t *ctx, struct de *, void *) ) {
|
||||||
|
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -28,13 +28,13 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void httplib_send_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers );
|
* void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers );
|
||||||
*
|
*
|
||||||
* The function httplib_send_file() sends a file to the other peer. Optionally
|
* The function httplib_send_file() sends a file to the other peer. Optionally
|
||||||
* the MIME type and additional headers can be specified.
|
* the MIME type and additional headers can be specified.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void httplib_send_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers ) {
|
void httplib_send_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, const char *mime_type, const char *additional_headers ) {
|
||||||
|
|
||||||
struct file file = STRUCT_FILE_INITIALIZER;
|
struct file file = STRUCT_FILE_INITIALIZER;
|
||||||
|
|
||||||
|
@@ -34,7 +34,7 @@
|
|||||||
* Send len bytes from the opened file to the client.
|
* Send len bytes from the opened file to the client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len ) {
|
void XX_httplib_send_file_data( struct lh_ctx_t *ctx, struct lh_con_t *conn, struct file *filep, int64_t offset, int64_t len ) {
|
||||||
|
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
void XX_httplib_send_http_error( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int status, const char *fmt, ... ) {
|
void XX_httplib_send_http_error( struct lh_ctx_t *ctx, struct lh_con_t *conn, int status, const char *fmt, ... ) {
|
||||||
|
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@@ -32,13 +32,13 @@
|
|||||||
#define B64_SHA_LEN (sizeof(sha)*2)
|
#define B64_SHA_LEN (sizeof(sha)*2)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key );
|
* int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_send_websocket_handshake() sends a handshake over
|
* The function XX_httplib_send_websocket_handshake() sends a handshake over
|
||||||
* a websocket connection.
|
* a websocket connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int XX_httplib_send_websocket_handshake( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ) {
|
int XX_httplib_send_websocket_handshake( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *websock_key ) {
|
||||||
|
|
||||||
static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
static const char *magic = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
|
||||||
const char *protocol;
|
const char *protocol;
|
||||||
|
@@ -54,7 +54,7 @@ typedef struct tagTHREADNAME_INFO {
|
|||||||
|
|
||||||
#endif /* __linux__ */
|
#endif /* __linux__ */
|
||||||
|
|
||||||
void XX_httplib_set_thread_name( const struct lh_ctx_t *ctx, const char *name ) {
|
void XX_httplib_set_thread_name( struct lh_ctx_t *ctx, const char *name ) {
|
||||||
|
|
||||||
char thread_name[16+1]; /* 16 = Max. thread length in Linux/OSX/.. */
|
char thread_name[16+1]; /* 16 = Max. thread length in Linux/OSX/.. */
|
||||||
|
|
||||||
|
@@ -29,14 +29,14 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... );
|
* void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_snprintf() is an internal function to send a string
|
* The function XX_httplib_snprintf() is an internal function to send a string
|
||||||
* to a connection. The string can be formated with a format string and
|
* to a connection. The string can be formated with a format string and
|
||||||
* parameters in the same way as the snprintf function works.
|
* parameters in the same way as the snprintf function works.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ) {
|
void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, ... ) {
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ static void trim_trailing_whitespaces( char *s ) {
|
|||||||
} /* trim_trailing_whitespaces */
|
} /* trim_trailing_whitespaces */
|
||||||
|
|
||||||
|
|
||||||
pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) {
|
pid_t XX_httplib_spawn_process( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) {
|
||||||
|
|
||||||
HANDLE me;
|
HANDLE me;
|
||||||
char *p;
|
char *p;
|
||||||
@@ -157,7 +157,7 @@ spawn_cleanup:
|
|||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
|
|
||||||
#ifndef NO_CGI
|
#ifndef NO_CGI
|
||||||
pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) {
|
pid_t XX_httplib_spawn_process( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *prog, char *envblk, char *envp[], int fdin[2], int fdout[2], int fderr[2], const char *dir ) {
|
||||||
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
const char *interp;
|
const char *interp;
|
||||||
|
@@ -29,10 +29,10 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
#include "httplib_utils.h"
|
#include "httplib_utils.h"
|
||||||
|
|
||||||
static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *, struct file *, int );
|
static void send_ssi_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *, struct file *, int );
|
||||||
|
|
||||||
|
|
||||||
static void do_ssi_include( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *ssi, char *tag, int include_level ) {
|
static void do_ssi_include( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *ssi, char *tag, int include_level ) {
|
||||||
|
|
||||||
char file_name[MG_BUF_LEN];
|
char file_name[MG_BUF_LEN];
|
||||||
char path[512];
|
char path[512];
|
||||||
@@ -127,7 +127,7 @@ static void do_ssi_include( const struct lh_ctx_t *ctx, struct lh_con_t *conn, c
|
|||||||
|
|
||||||
|
|
||||||
#if !defined(NO_POPEN)
|
#if !defined(NO_POPEN)
|
||||||
static void do_ssi_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *tag ) {
|
static void do_ssi_exec( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *tag ) {
|
||||||
|
|
||||||
char cmd[1024] = "";
|
char cmd[1024] = "";
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
@@ -165,7 +165,7 @@ static int httplib_fgetc( struct file *filep, int offset ) {
|
|||||||
} /* httplib_fgetc */
|
} /* httplib_fgetc */
|
||||||
|
|
||||||
|
|
||||||
static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, int include_level ) {
|
static void send_ssi_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep, int include_level ) {
|
||||||
|
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
int ch;
|
int ch;
|
||||||
@@ -269,7 +269,7 @@ static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, co
|
|||||||
} /* send_ssi_file */
|
} /* send_ssi_file */
|
||||||
|
|
||||||
|
|
||||||
void XX_httplib_handle_ssi_file_request( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
void XX_httplib_handle_ssi_file_request( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
char date[64];
|
char date[64];
|
||||||
char error_string[ERROR_STRING_LEN];
|
char error_string[ERROR_STRING_LEN];
|
||||||
|
@@ -140,8 +140,8 @@ void XX_httplib_ssl_get_client_cert_info( struct lh_con_t *conn );
|
|||||||
long XX_httplib_ssl_get_protocol( int version_id );
|
long XX_httplib_ssl_get_protocol( int version_id );
|
||||||
unsigned long XX_httplib_ssl_id_callback( void );
|
unsigned long XX_httplib_ssl_id_callback( void );
|
||||||
void XX_httplib_ssl_locking_callback( int mode, int mutex_num, const char *file, int line );
|
void XX_httplib_ssl_locking_callback( int mode, int mutex_num, const char *file, int line );
|
||||||
int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem );
|
int XX_httplib_ssl_use_pem_file( struct lh_ctx_t *ctx, const char *pem );
|
||||||
int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) );
|
int XX_httplib_sslize( struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) );
|
||||||
void XX_httplib_tls_dtor( void *key );
|
void XX_httplib_tls_dtor( void *key );
|
||||||
void XX_httplib_uninitialize_ssl( struct lh_ctx_t *ctx );
|
void XX_httplib_uninitialize_ssl( struct lh_ctx_t *ctx );
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "httplib_ssl.h"
|
#include "httplib_ssl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem );
|
* int XX_httplib_ssl_use_pem_file( struct lh_ctx_t *ctx, const char *pem );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_ssl_use_pem_file() tries to use a certificate which
|
* The function XX_httplib_ssl_use_pem_file() tries to use a certificate which
|
||||||
* is passed as a parameter with the filename of the certificate.
|
* is passed as a parameter with the filename of the certificate.
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
#if ! defined(NO_SSL)
|
#if ! defined(NO_SSL)
|
||||||
|
|
||||||
int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ) {
|
int XX_httplib_ssl_use_pem_file( struct lh_ctx_t *ctx, const char *pem ) {
|
||||||
|
|
||||||
if ( ctx == NULL || pem == NULL ) return 0;
|
if ( ctx == NULL || pem == NULL ) return 0;
|
||||||
|
|
||||||
|
@@ -29,14 +29,14 @@
|
|||||||
#include "httplib_ssl.h"
|
#include "httplib_ssl.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int XX_httplib_sslize( struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) );
|
* int XX_httplib_sslize( lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) );
|
||||||
*
|
*
|
||||||
* The fucntion XX_httplib_sslize() initiates SSL on a connection.
|
* The fucntion XX_httplib_sslize() initiates SSL on a connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if !defined(NO_SSL)
|
#if !defined(NO_SSL)
|
||||||
|
|
||||||
int XX_httplib_sslize( const struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ) {
|
int XX_httplib_sslize( struct lh_ctx_t *ctx, struct lh_con_t *conn, SSL_CTX *s, int (*func)(SSL *) ) {
|
||||||
|
|
||||||
int ret;
|
int ret;
|
||||||
int err;
|
int err;
|
||||||
|
@@ -43,7 +43,7 @@ struct lh_ctx_t *httplib_start( const struct lh_clb_t *callbacks, void *user_dat
|
|||||||
|
|
||||||
struct lh_ctx_t *ctx;
|
struct lh_ctx_t *ctx;
|
||||||
int i;
|
int i;
|
||||||
void (*exit_callback)(const struct lh_ctx_t *ctx);
|
void (*exit_callback)(struct lh_ctx_t *ctx);
|
||||||
struct httplib_workerTLS tls;
|
struct httplib_workerTLS tls;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -48,7 +48,7 @@ static bool path_cannot_disclose_cgi( const char *path ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int XX_httplib_stat( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
wchar_t wbuf[PATH_MAX];
|
wchar_t wbuf[PATH_MAX];
|
||||||
WIN32_FILE_ATTRIBUTE_DATA info;
|
WIN32_FILE_ATTRIBUTE_DATA info;
|
||||||
@@ -121,7 +121,7 @@ int XX_httplib_stat( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const ch
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int XX_httplib_stat( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
int XX_httplib_stat( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path, struct file *filep ) {
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@@ -28,14 +28,14 @@
|
|||||||
#include "httplib_main.h"
|
#include "httplib_main.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int64_t httplib_store_body( struct lh_con_t *conn, const char *path );
|
* int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path );
|
||||||
*
|
*
|
||||||
* The function httplib_store_body() stores in incoming body for future
|
* The function httplib_store_body() stores in incoming body for future
|
||||||
* processing. The function returns the number of bytes actually read, or a
|
* processing. The function returns the number of bytes actually read, or a
|
||||||
* negative number to indicate a failure.
|
* negative number to indicate a failure.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
int64_t httplib_store_body( struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *path ) {
|
||||||
|
|
||||||
char buf[MG_BUF_LEN];
|
char buf[MG_BUF_LEN];
|
||||||
int64_t len;
|
int64_t len;
|
||||||
|
@@ -22,6 +22,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void XX_httplib_snprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(6, 7);
|
void XX_httplib_snprintf( struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(6, 7);
|
||||||
int XX_httplib_vprintf( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *fmt, va_list ap );
|
int XX_httplib_vprintf( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const char *fmt, va_list ap );
|
||||||
void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap );
|
void XX_httplib_vsnprintf( struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap );
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include "httplib_string.h"
|
#include "httplib_string.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* bool XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep );
|
* bool XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep );
|
||||||
*
|
*
|
||||||
* The function XX_httplib_substiture_index_file() tries to find an index file
|
* The function XX_httplib_substiture_index_file() tries to find an index file
|
||||||
* matching a given directory path. The function returns true of an index file
|
* matching a given directory path. The function returns true of an index file
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
* located, it's stats are returnd in stp.
|
* located, it's stats are returnd in stp.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int XX_httplib_substitute_index_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ) {
|
int XX_httplib_substitute_index_file( struct lh_ctx_t *ctx, struct lh_con_t *conn, char *path, size_t path_len, struct file *filep ) {
|
||||||
|
|
||||||
const char *list;
|
const char *list;
|
||||||
struct file file = STRUCT_FILE_INITIALIZER;
|
struct file file = STRUCT_FILE_INITIALIZER;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#define LEAP_YEAR(x) ( ((x)%4) == 0 && ( ((x)%100) != 0 || ((x)%400) == 0 ) )
|
#define LEAP_YEAR(x) ( ((x)%4) == 0 && ( ((x)%100) != 0 || ((x)%400) == 0 ) )
|
||||||
|
|
||||||
void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(3, 4);
|
void XX_httplib_addenv( struct lh_ctx_t *ctx, struct cgi_environment *env, PRINTF_FORMAT_STRING(const char *fmt), ... ) PRINTF_ARGS(3, 4);
|
||||||
double XX_httplib_difftimespec( const struct timespec *ts_now, const struct timespec *ts_before );
|
double XX_httplib_difftimespec( const struct timespec *ts_now, const struct timespec *ts_before );
|
||||||
void XX_httplib_gmt_time_string( char *buf, size_t buf_len, time_t *t );
|
void XX_httplib_gmt_time_string( char *buf, size_t buf_len, time_t *t );
|
||||||
int XX_httplib_inet_pton( int af, const char *src, void *dst, size_t dstlen );
|
int XX_httplib_inet_pton( int af, const char *src, void *dst, size_t dstlen );
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
* Report errors if length is exceeded.
|
* Report errors if length is exceeded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ) {
|
void XX_httplib_vsnprintf( struct lh_ctx_t *ctx, const struct lh_con_t *conn, bool *truncated, char *buf, size_t buflen, const char *fmt, va_list ap ) {
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
bool ok;
|
bool ok;
|
||||||
|
@@ -31,14 +31,14 @@
|
|||||||
static void mask_data( const char *in, size_t in_len, uint32_t masking_key, char *out );
|
static void mask_data( const char *in, size_t in_len, uint32_t masking_key, char *out );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* int httplib_websocket_client_write( struct lh_con_t *conn, int opcode, const char *data, size_t dataLen );
|
* int httplib_websocket_client_write( struct lh_ctx *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen );
|
||||||
*
|
*
|
||||||
* The function httplib_websocket_client_write() is used to write as a client
|
* The function httplib_websocket_client_write() is used to write as a client
|
||||||
* to a websocket server. The function returns -1 if an error occures,
|
* to a websocket server. The function returns -1 if an error occures,
|
||||||
* otherwise the amount of bytes written.
|
* otherwise the amount of bytes written.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ) {
|
int httplib_websocket_client_write( struct lh_ctx_t *ctx, struct lh_con_t *conn, int opcode, const char *data, size_t dataLen ) {
|
||||||
|
|
||||||
int retval;
|
int retval;
|
||||||
char *masked_data;
|
char *masked_data;
|
||||||
|
Reference in New Issue
Block a user