mirror of
https://github.com/lammertb/libhttp.git
synced 2025-08-06 05:02:40 +03:00
Renamed debug options
This commit is contained in:
@@ -184,17 +184,17 @@ struct pollfd {
|
||||
|
||||
/************************************************************************************************/
|
||||
/* */
|
||||
/* enum debug_level_t; */
|
||||
/* enum lh_dbg_t; */
|
||||
/* */
|
||||
/* Error messages are generated depending on the debug level of a context. Different contexts */
|
||||
/* can have different debug levels allowing an application to only generate debug messages of */
|
||||
/* specific servers or client connections. */
|
||||
enum debug_level_t { /* */
|
||||
DEBUG_LEVEL_NONE = 0x00, /* No error messages are generated at all */
|
||||
DEBUG_LEVEL_CRASH = 0x10, /* Messages for errors impacting multiple connections in a severe way are generated */
|
||||
DEBUG_LEVEL_ERROR = 0x20, /* Messages for errors impacting single connections in a severe way are generated (default) */
|
||||
DEBUG_LEVEL_WARNING = 0x30, /* Messages for errors impacting single connections in a minor way are generated */
|
||||
DEBUG_LEVEL_INFO = 0x40 /* All error, warning and informational messages are generated */
|
||||
enum lh_dbg_t { /* */
|
||||
LH_DEBUG_NONE = 0x00, /* No error messages are generated at all */
|
||||
LH_DEBUG_CRASH = 0x10, /* Messages for errors impacting multiple connections in a severe way are generated */
|
||||
LH_DEBUG_ERROR = 0x20, /* Messages for errors impacting single connections in a severe way are generated (default) */
|
||||
LH_DEBUG_WARNING = 0x30, /* Messages for errors impacting single connections in a minor way are generated */
|
||||
LH_DEBUG_INFO = 0x40 /* All error, warning and informational messages are generated */
|
||||
}; /* */
|
||||
/************************************************************************************************/
|
||||
|
||||
@@ -375,13 +375,13 @@ 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_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 void httplib_cry( enum debug_level_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, 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_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 char * httplib_error_string( int error_code, char *buf, size_t buf_len );
|
||||
LIBHTTP_API const char * httplib_get_builtin_mime_type( const char *file_name );
|
||||
LIBHTTP_API int httplib_get_cookie( const char *cookie, const char *var_name, char *buf, size_t buf_len );
|
||||
LIBHTTP_API enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx );
|
||||
LIBHTTP_API enum lh_dbg_t httplib_get_debug_level( struct lh_ctx_t *ctx );
|
||||
LIBHTTP_API const char * httplib_get_header( const struct lh_con_t *conn, const char *name );
|
||||
LIBHTTP_API const char * httplib_get_option( const struct lh_ctx_t *ctx, const char *name, char *buffer, size_t buflen );
|
||||
LIBHTTP_API uint64_t httplib_get_random( void );
|
||||
@@ -428,7 +428,7 @@ 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_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 enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level );
|
||||
LIBHTTP_API enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level );
|
||||
LIBHTTP_API void httplib_set_request_handler( struct lh_ctx_t *ctx, const char *uri, httplib_request_handler handler, void *cbdata );
|
||||
LIBHTTP_API void httplib_set_user_connection_data( struct lh_con_t *conn, void *data );
|
||||
LIBHTTP_API void httplib_set_websocket_handler( struct lh_ctx_t *ctx, const char *uri, httplib_websocket_connect_handler connect_handler, httplib_websocket_ready_handler ready_handler, httplib_websocket_data_handler data_handler, httplib_websocket_close_handler close_handler, void *cbdata );
|
||||
|
@@ -44,7 +44,7 @@ struct lh_ctx_t *XX_httplib_abort_start( struct lh_ctx_t *ctx, const char *fmt,
|
||||
va_end( ap );
|
||||
buf[sizeof(buf)-1] = 0;
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: %s", __func__, buf );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: %s", __func__, buf );
|
||||
}
|
||||
|
||||
XX_httplib_free_context( ctx );
|
||||
|
@@ -54,7 +54,7 @@ void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_
|
||||
if ( ! XX_httplib_check_acl( ctx, ntohl(*(uint32_t *)&so.rsa.sin.sin_addr )) ) {
|
||||
|
||||
XX_httplib_sockaddr_to_string( src_addr, sizeof(src_addr), &so.rsa );
|
||||
httplib_cry( DEBUG_LEVEL_INFO, ctx, NULL, "%s: %s is not allowed to connect", __func__, src_addr );
|
||||
httplib_cry( LH_DEBUG_INFO, ctx, NULL, "%s: %s is not allowed to connect", __func__, src_addr );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_
|
||||
|
||||
if ( getsockname( so.sock, &so.lsa.sa, &len ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: getsockname() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: getsockname() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -86,7 +86,7 @@ void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_
|
||||
|
||||
if ( setsockopt( so.sock, SOL_SOCKET, SO_KEEPALIVE, (SOCK_OPT_TYPE)&on, sizeof(on) ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: setsockopt(SOL_SOCKET SO_KEEPALIVE) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: setsockopt(SOL_SOCKET SO_KEEPALIVE) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -100,7 +100,7 @@ void XX_httplib_accept_new_connection( const struct socket *listener, struct lh_
|
||||
|
||||
if ( ctx->tcp_nodelay && XX_httplib_set_tcp_nodelay( so.sock, 1 ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: setsockopt(IPPROTO_TCP TCP_NODELAY) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: setsockopt(IPPROTO_TCP TCP_NODELAY) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
if ( ctx->request_timeout > 0 ) XX_httplib_set_sock_timeout( so.sock, ctx->request_timeout );
|
||||
|
@@ -79,7 +79,7 @@ void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env,
|
||||
* Out of memory
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, env->conn, "%s: Cannot allocate memory for CGI variable [%s]", __func__, fmt );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, env->conn, "%s: Cannot allocate memory for CGI variable [%s]", __func__, fmt );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ void XX_httplib_addenv( const struct lh_ctx_t *ctx, struct cgi_environment *env,
|
||||
|
||||
if ( space < 2 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, env->conn, "%s: Cannot register CGI variable [%s]", __func__, fmt );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, env->conn, "%s: Cannot register CGI variable [%s]", __func__, fmt );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ int XX_httplib_check_acl( struct lh_ctx_t *ctx, uint32_t remote_ip ) {
|
||||
|
||||
if ( (flag != '+' && flag != '-') || XX_httplib_parse_net( &vec.ptr[1], &net, &mask ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, NULL, "%s: subnet must be [+|-]x.x.x.x[/x]", __func__ );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, NULL, "%s: subnet must be [+|-]x.x.x.x[/x]", __func__ );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ bool XX_httplib_check_authorization( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
|
||||
if ( truncated || ! XX_httplib_fopen( ctx, conn, fname, "r", &file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: cannot open %s: %s", __func__, fname, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: cannot open %s: %s", __func__, fname, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -67,7 +67,7 @@ void XX_httplib_close_socket_gracefully( const struct lh_ctx_t *ctx, struct lh_c
|
||||
else {
|
||||
if ( setsockopt( conn->client.sock, SOL_SOCKET, SO_LINGER, (char *)&linger, sizeof(linger) ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: setsockopt(SOL_SOCKET SO_LINGER) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: setsockopt(SOL_SOCKET SO_LINGER) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -89,14 +89,14 @@ static struct lh_con_t *httplib_connect_client_impl( struct lh_ctx_t *ctx, const
|
||||
|
||||
if ( (conn = httplib_calloc( 1, sizeof(*conn) + MAX_REQUEST_SIZE )) == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: calloc(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: calloc(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( sock );
|
||||
}
|
||||
#ifndef NO_SSL
|
||||
|
||||
else if ( use_ssl && (conn->client_ssl_ctx = SSL_CTX_new(SSLv23_client_method())) == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: SSL_CTX_new error", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: SSL_CTX_new error", __func__ );
|
||||
closesocket( sock );
|
||||
conn = httplib_free( conn );
|
||||
}
|
||||
@@ -112,7 +112,7 @@ static struct lh_con_t *httplib_connect_client_impl( struct lh_ctx_t *ctx, const
|
||||
conn->client.sock = sock;
|
||||
conn->client.lsa = sa;
|
||||
|
||||
if ( getsockname( sock, psa, &len ) != 0 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: getsockname() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
if ( getsockname( sock, psa, &len ) != 0 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: getsockname() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
|
||||
conn->client.has_ssl = (use_ssl) ? true : false;
|
||||
httplib_pthread_mutex_init( &conn->mutex, &XX_httplib_pthread_mutex_attr );
|
||||
@@ -136,7 +136,7 @@ static struct lh_con_t *httplib_connect_client_impl( struct lh_ctx_t *ctx, const
|
||||
|
||||
if ( ! XX_httplib_ssl_use_pem_file( ctx, client_options->client_cert ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: can not use SSL client certificate", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: can not use SSL client certificate", __func__ );
|
||||
SSL_CTX_free( conn->client_ssl_ctx );
|
||||
closesocket( sock );
|
||||
conn = httplib_free( conn );
|
||||
@@ -153,7 +153,7 @@ static struct lh_con_t *httplib_connect_client_impl( struct lh_ctx_t *ctx, const
|
||||
|
||||
if ( ! XX_httplib_sslize( ctx, conn, conn->client_ssl_ctx, SSL_connect ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: SSL connection error", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: SSL connection error", __func__ );
|
||||
SSL_CTX_free( conn->client_ssl_ctx );
|
||||
closesocket( sock );
|
||||
conn = httplib_free( conn );
|
||||
|
@@ -54,13 +54,13 @@ bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port
|
||||
|
||||
if ( host == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: NULL host", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: NULL host", __func__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( port < 0 || ! XX_httplib_is_valid_port( (unsigned)port) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: invalid port", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: invalid port", __func__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port
|
||||
|
||||
if ( use_ssl && SSLv23_client_method == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: SSL is not initialized", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: SSL is not initialized", __func__ );
|
||||
return false;
|
||||
}
|
||||
#else /* NO_SSL */
|
||||
@@ -112,7 +112,7 @@ bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port
|
||||
|
||||
if ( ip_ver == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: host not found", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: host not found", __func__ );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port
|
||||
|
||||
if ( *sock == INVALID_SOCKET ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: socket(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: socket(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ bool XX_httplib_connect_socket( struct lh_ctx_t *ctx, const char *host, int port
|
||||
* Not connected
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: connect(%s:%d): %s", __func__, host, port, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: connect(%s:%d): %s", __func__, host, port, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( *sock );
|
||||
*sock = INVALID_SOCKET;
|
||||
|
||||
|
@@ -47,7 +47,7 @@ struct lh_con_t *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const c
|
||||
|
||||
if ( ctx->status != CTX_STATUS_TERMINATED ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: client context not in terminated state", __func__ );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: client context not in terminated state", __func__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ struct lh_con_t *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const c
|
||||
conn = httplib_download( ctx, host, port, use_ssl, handshake_req, path, host, magic, origin );
|
||||
if ( conn == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: init of download failed", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: init of download failed", __func__ );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( strcmp( conn->request_info.request_uri, "101" ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: unexpected server reply \"%s\"", __func__, conn->request_info.request_uri );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: unexpected server reply \"%s\"", __func__, conn->request_info.request_uri );
|
||||
|
||||
conn = httplib_free( conn );
|
||||
return NULL;
|
||||
@@ -94,7 +94,7 @@ struct lh_con_t *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const c
|
||||
|
||||
if ( ctx->workerthreadids == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: out of memory allocating worker thread IDs", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: out of memory allocating worker thread IDs", __func__ );
|
||||
|
||||
ctx->num_threads = 0;
|
||||
ctx->user_data = NULL;
|
||||
@@ -107,7 +107,7 @@ struct lh_con_t *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const c
|
||||
|
||||
if ( thread_data == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: out of memory allocating thread data", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: out of memory allocating thread data", __func__ );
|
||||
|
||||
ctx->workerthreadids = httplib_free( ctx->workerthreadids );
|
||||
ctx->num_threads = 0;
|
||||
@@ -131,7 +131,7 @@ struct lh_con_t *httplib_connect_websocket_client( struct lh_ctx_t *ctx, const c
|
||||
|
||||
if ( XX_httplib_start_thread_with_id( XX_httplib_websocket_client_thread, thread_data, ctx->workerthreadids) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: thread failed to start", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: thread failed to start", __func__ );
|
||||
|
||||
thread_data = httplib_free( thread_data );
|
||||
conn = httplib_free( conn );
|
||||
|
@@ -26,14 +26,14 @@
|
||||
#include "httplib_ssl.h"
|
||||
|
||||
/*
|
||||
* void httplib_cry( enum debug_level_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, const 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
|
||||
* 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.
|
||||
*/
|
||||
|
||||
void httplib_cry( enum debug_level_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, const struct lh_ctx_t *ctx, const struct lh_con_t *conn, const char *fmt, ... ) {
|
||||
|
||||
char buf[MG_BUF_LEN];
|
||||
char src_addr[IP_ADDR_STR_LEN];
|
||||
|
@@ -52,7 +52,7 @@ struct lh_con_t *httplib_download( struct lh_ctx_t *ctx, const char *host, int p
|
||||
|
||||
i = XX_httplib_vprintf( ctx, conn, fmt, ap );
|
||||
|
||||
if ( i <= 0 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: error sending request", __func__ );
|
||||
if ( i <= 0 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: error sending request", __func__ );
|
||||
|
||||
else {
|
||||
XX_httplib_getreq( ctx, conn, &reqerr );
|
||||
|
@@ -39,7 +39,7 @@ void XX_httplib_fclose_on_exec( const struct lh_ctx_t *ctx, struct file *filep,
|
||||
|
||||
if ( fcntl( fileno( filep->fp ), F_SETFD, FD_CLOEXEC) != 0 ) {
|
||||
|
||||
if ( conn != NULL ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: fcntl(F_SETFD FD_CLOEXEC) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
if ( conn != NULL ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: fcntl(F_SETFD FD_CLOEXEC) failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -23,15 +23,15 @@
|
||||
#include "httplib_main.h"
|
||||
|
||||
/*
|
||||
* enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx );
|
||||
* enum lh_dbg_t httplib_get_debug_level( struct lh_ctx_t *ctx );
|
||||
*
|
||||
* The function httplib_get_debug_level() returns the debug level for a
|
||||
* context.
|
||||
*/
|
||||
|
||||
enum debug_level_t httplib_get_debug_level( struct lh_ctx_t *ctx ) {
|
||||
enum lh_dbg_t httplib_get_debug_level( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( ctx == NULL ) return DEBUG_LEVEL_NONE;
|
||||
if ( ctx == NULL ) return LH_DEBUG_NONE;
|
||||
return ctx->debug_level;
|
||||
|
||||
} /* httplib_get_debug_level */
|
||||
|
@@ -118,7 +118,7 @@ const char *httplib_get_response_code_text( const struct lh_ctx_t *ctx, struct l
|
||||
* This error code is unknown. This should not happen.
|
||||
*/
|
||||
|
||||
if ( ctx != NULL && conn != NULL ) httplib_cry( DEBUG_LEVEL_INFO, ctx, conn, "%s: unknown HTTP response code: %u", __func__, response_code );
|
||||
if ( ctx != NULL && conn != NULL ) httplib_cry( LH_DEBUG_INFO, ctx, conn, "%s: unknown HTTP response code: %u", __func__, response_code );
|
||||
|
||||
/*
|
||||
* Return at least a category according to RFC 2616 Section 10.
|
||||
|
@@ -44,7 +44,7 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
if ( conn == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: internal error", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: internal error", __func__ );
|
||||
*err = 500;
|
||||
return false;
|
||||
}
|
||||
@@ -66,14 +66,14 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
if ( conn->request_len >= 0 && conn->data_len < conn->request_len ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: invalid request size", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: invalid request size", __func__ );
|
||||
*err = 500;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( conn->request_len == 0 && conn->data_len == conn->buf_size ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: request too large", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: request too large", __func__ );
|
||||
*err = 413;
|
||||
return false;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
if ( conn->data_len > 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: client sent malformed request", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: client sent malformed request", __func__ );
|
||||
*err = 400;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
conn->must_close = true;
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: client did not send a request", __func__ );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: client did not send a request", __func__ );
|
||||
*err = 0;
|
||||
}
|
||||
return false;
|
||||
@@ -101,7 +101,7 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
else if ( XX_httplib_parse_http_message( conn->buf, conn->buf_size, &conn->request_info ) <= 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: bad request", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: bad request", __func__ );
|
||||
*err = 400;
|
||||
return false;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ bool XX_httplib_getreq( const struct lh_ctx_t *ctx, struct lh_con_t *conn, int *
|
||||
|
||||
if ( endptr == cl ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: bad request", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: bad request", __func__ );
|
||||
*err = 411;
|
||||
return false;
|
||||
}
|
||||
|
@@ -85,7 +85,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
|
||||
if ( truncated ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Path too long", __func__, prog );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Path too long", __func__, prog );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: %s", "CGI path too long" );
|
||||
|
||||
goto done;
|
||||
@@ -106,7 +106,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( pipe(fdin) != 0 || pipe(fdout) != 0 || pipe(fderr) != 0 ) {
|
||||
|
||||
status = httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not create CGI pipes: %s", __func__, prog, status );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not create CGI pipes: %s", __func__, prog, status );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: Cannot create CGI pipe: %s", status );
|
||||
|
||||
goto done;
|
||||
@@ -117,7 +117,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( pid == (pid_t)-1 ) {
|
||||
|
||||
status = httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not spawn CGI process: %s", __func__, prog, status );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not spawn CGI process: %s", __func__, prog, status );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: Cannot spawn CGI process [%s]: %s", prog, status );
|
||||
|
||||
goto done;
|
||||
@@ -152,7 +152,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( (in = fdopen( fdin[1], "wb" )) == NULL ) {
|
||||
|
||||
status = httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stdin: %s", __func__, prog, status );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stdin: %s", __func__, prog, status );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: CGI can not open fdin\nfopen: %s", status );
|
||||
|
||||
goto done;
|
||||
@@ -161,7 +161,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( (out = fdopen( fdout[0], "rb" )) == NULL ) {
|
||||
|
||||
status = httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stdout: %s", __func__, prog, status );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stdout: %s", __func__, prog, status );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: CGI can not open fdout\nfopen: %s", status );
|
||||
|
||||
goto done;
|
||||
@@ -170,7 +170,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( (err = fdopen( fderr[0], "rb" )) == NULL ) {
|
||||
|
||||
status = httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stderr: %s", __func__, prog, status );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Can not open stderr: %s", __func__, prog, status );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: CGI can not open fdout\nfopen: %s", status );
|
||||
|
||||
goto done;
|
||||
@@ -194,7 +194,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
* Error sending the body data
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Forward body data failed", __func__, prog );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Forward body data failed", __func__, prog );
|
||||
|
||||
goto done;
|
||||
}
|
||||
@@ -222,7 +222,7 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
if ( buf == NULL ) {
|
||||
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: Not enough memory for CGI buffer (%u bytes)", (unsigned int)buflen );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\": Not enough memory for buffer (%u " "bytes)", __func__, prog, (unsigned int)buflen );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\": Not enough memory for buffer (%u " "bytes)", __func__, prog, (unsigned int)buflen );
|
||||
|
||||
goto done;
|
||||
}
|
||||
@@ -239,12 +239,12 @@ void XX_httplib_handle_cgi_request( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
|
||||
if ( i > 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program \"%s\" sent error " "message: [%.*s]", __func__, prog, i, buf );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program \"%s\" sent error " "message: [%.*s]", __func__, prog, i, buf );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "Error: CGI program \"%s\" sent error " "message: [%.*s]", prog, i, buf );
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CGI program sent malformed or too big " "(>%u bytes) HTTP headers: [%.*s]", __func__, (unsigned)buflen, data_len, buf );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CGI program sent malformed or too big " "(>%u bytes) HTTP headers: [%.*s]", __func__, (unsigned)buflen, data_len, buf );
|
||||
|
||||
XX_httplib_send_http_error( ctx, conn,
|
||||
500,
|
||||
|
@@ -48,7 +48,7 @@ static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct lh_
|
||||
* Log error message and skip this field.
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: Cannot decode filename", __func__ );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: Cannot decode filename", __func__ );
|
||||
return FORM_FIELD_STORAGE_SKIP;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct lh_
|
||||
|
||||
if ( fdh->field_get == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: Function \"Get\" not available", __func__ );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: Function \"Get\" not available", __func__ );
|
||||
return FORM_FIELD_STORAGE_SKIP;
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ static int url_encoded_field_found( const struct lh_ctx_t *ctx, const struct lh_
|
||||
|
||||
if ( fdh->field_store == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: Function \"Store\" not available", __func__ );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: Function \"Store\" not available", __func__ );
|
||||
return FORM_FIELD_STORAGE_SKIP;
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ static int url_encoded_field_get( const struct lh_ctx_t *ctx, const struct lh_co
|
||||
* Log error message and stop parsing the form data.
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Not enough memory (required: %lu)", __func__, (unsigned long)(value_len + 1));
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Not enough memory (required: %lu)", __func__, (unsigned long)(value_len + 1));
|
||||
return FORM_FIELD_STORAGE_ABORT;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
|
||||
size_t n = (size_t)fwrite(val, 1, (size_t)vallen, fstore.fp);
|
||||
if ((n != (size_t)vallen) || (ferror(fstore.fp))) {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
fclose( fstore.fp );
|
||||
fstore.fp = NULL;
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
@@ -290,14 +290,14 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
}
|
||||
|
||||
fstore.fp = NULL;
|
||||
}
|
||||
|
||||
} else httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path );
|
||||
} else httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path );
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -398,7 +398,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
|
||||
if ( XX_httplib_fopen( ctx, conn, path, "wb", &fstore ) == 0 ) fstore.fp = NULL;
|
||||
file_size = 0;
|
||||
if (!fstore.fp) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path);
|
||||
if (!fstore.fp) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path);
|
||||
}
|
||||
|
||||
get_block = 0;
|
||||
@@ -443,7 +443,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
if ( fstore.fp ) {
|
||||
size_t n = (size_t)fwrite(val, 1, (size_t)vallen, fstore.fp);
|
||||
if ((n != (size_t)vallen) || (ferror(fstore.fp))) {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path);
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path);
|
||||
fclose(fstore.fp);
|
||||
fstore.fp = NULL;
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
@@ -494,7 +494,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
if ( XX_httplib_fopen( ctx, conn, path, "wb", &fstore ) == 0 ) fstore.fp = NULL;
|
||||
file_size = 0;
|
||||
|
||||
if ( ! fstore.fp ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path );
|
||||
if ( ! fstore.fp ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot create file %s", __func__, path );
|
||||
}
|
||||
|
||||
get_block = 0;
|
||||
@@ -740,7 +740,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
|
||||
if ( n != towrite || ferror( fstore.fp ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
fclose( fstore.fp );
|
||||
fstore.fp = NULL;
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
@@ -796,7 +796,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
|
||||
if ( n != towrite || ferror( fstore.fp ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot write file %s", __func__, path );
|
||||
fclose( fstore.fp );
|
||||
fstore.fp = NULL;
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
@@ -820,7 +820,7 @@ int httplib_handle_form_request( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Error saving file %s", __func__, path );
|
||||
XX_httplib_remove_bad_file( ctx, conn, path );
|
||||
}
|
||||
fstore.fp = NULL;
|
||||
|
@@ -116,7 +116,7 @@ void XX_httplib_handle_request( struct lh_ctx_t *ctx, struct lh_con_t *conn ) {
|
||||
*/
|
||||
|
||||
XX_httplib_send_http_error( ctx, conn, 503, "%s", "Error: SSL forward not configured properly" );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: can not redirect to SSL, no SSL port available", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: can not redirect to SSL, no SSL port available", __func__ );
|
||||
}
|
||||
|
||||
return;
|
||||
|
@@ -43,7 +43,7 @@ bool XX_httplib_init_options( struct lh_ctx_t *ctx ) {
|
||||
ctx->cgi_environment = NULL;
|
||||
ctx->cgi_interpreter = NULL;
|
||||
ctx->cgi_pattern = NULL;
|
||||
ctx->debug_level = DEBUG_LEVEL_WARNING;
|
||||
ctx->debug_level = LH_DEBUG_WARNING;
|
||||
ctx->decode_url = true;
|
||||
ctx->document_root = NULL;
|
||||
ctx->enable_directory_listing = true;
|
||||
|
@@ -78,7 +78,7 @@ int XX_httplib_initialize_ssl( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( (XX_httplib_ssl_mutexes = httplib_malloc( size )) == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot allocate mutexes: %s", __func__, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot allocate mutexes: %s", __func__, XX_httplib_ssl_error() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -82,7 +82,7 @@ void *XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ss
|
||||
|
||||
if ( dll_handle == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot load %s", __func__, dll_name );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot load %s", __func__, dll_name );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ void *XX_httplib_load_dll( struct lh_ctx_t *ctx, const char *dll_name, struct ss
|
||||
|
||||
if ( u.fp == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: %s: cannot find %s", __func__, dll_name, fp->name );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: %s: cannot find %s", __func__, dll_name, fp->name );
|
||||
dlclose( dll_handle );
|
||||
|
||||
return NULL;
|
||||
|
@@ -563,7 +563,7 @@ struct lh_ctx_t {
|
||||
struct ttimers *timers;
|
||||
#endif
|
||||
|
||||
enum debug_level_t debug_level;
|
||||
enum lh_dbg_t debug_level;
|
||||
|
||||
char * access_control_allow_origin;
|
||||
char * access_control_list;
|
||||
|
@@ -58,7 +58,7 @@ void XX_httplib_mkcol( const struct lh_ctx_t *ctx, struct lh_con_t *conn, const
|
||||
|
||||
if ( ! XX_httplib_stat( ctx, conn, path, & de.file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
if ( de.file.last_modified ) {
|
||||
|
@@ -55,7 +55,7 @@ void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( ! XX_httplib_fopen( ctx, conn, gpass, "r", filep ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, gpass, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, gpass, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
/*
|
||||
* Important: using local struct file to test path for is_directory
|
||||
@@ -71,7 +71,7 @@ void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( truncated || ! XX_httplib_fopen( ctx, conn, name, "r", filep ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, name, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, name, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void XX_httplib_open_auth_file( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( truncated || ! XX_httplib_fopen( ctx, conn, name, "r", filep ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, name, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_INFO, ctx, conn, "%s: fopen(%s): %s", __func__, name, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -138,7 +138,7 @@ void XX_httplib_prepare_cgi_environment( const struct lh_ctx_t *ctx, struct lh_c
|
||||
XX_httplib_snprintf( ctx, conn, &truncated, http_var_name, sizeof(http_var_name), "HTTP_%s", conn->request_info.http_headers[i].name );
|
||||
|
||||
if ( truncated ) {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: HTTP header variable too long [%s]", __func__, conn->request_info.http_headers[i].name );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: HTTP header variable too long [%s]", __func__, conn->request_info.http_headers[i].name );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -77,7 +77,7 @@ void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct lh_con_t *c
|
||||
|
||||
else if ( strcmp( ri->http_version, "1.0" ) && strcmp( ri->http_version, "1.1" ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: bad HTTP version \"%s\"", __func__, ri->http_version );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: bad HTTP version \"%s\"", __func__, ri->http_version );
|
||||
XX_httplib_send_http_error( ctx, conn, 505, "%s", httplib_get_response_code_text( ctx, conn, 505 ) );
|
||||
|
||||
was_error = true;
|
||||
@@ -109,7 +109,7 @@ void XX_httplib_process_new_connection( struct lh_ctx_t *ctx, struct lh_con_t *c
|
||||
break;
|
||||
|
||||
default :
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: invalid URI", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: invalid URI", __func__ );
|
||||
XX_httplib_send_http_error( ctx, conn, 400, "%s", httplib_get_response_code_text( ctx, conn, 400 ) );
|
||||
|
||||
conn->request_info.local_uri = NULL;
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "httplib_main.h"
|
||||
|
||||
static bool check_bool( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, bool *config );
|
||||
static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, enum debug_level_t *config );
|
||||
static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, enum lh_dbg_t *config );
|
||||
static bool check_dir( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, char **config );
|
||||
static bool check_file( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, char **config );
|
||||
static bool check_int( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, int *config, int minval, int maxval );
|
||||
@@ -297,7 +297,7 @@ static bool check_int( struct lh_ctx_t *ctx, const struct lh_opt_t *option, cons
|
||||
} /* check_int */
|
||||
|
||||
/*
|
||||
* static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name );
|
||||
* static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, enum lh_dbg_t *config );
|
||||
*
|
||||
* The function check_dbg() checks if an option is equal to a debug level
|
||||
* config parameter and stores the value if that is the case. If the value
|
||||
@@ -307,7 +307,7 @@ static bool check_int( struct lh_ctx_t *ctx, const struct lh_opt_t *option, cons
|
||||
* valid, also false is returned.
|
||||
*/
|
||||
|
||||
static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, enum debug_level_t *config ) {
|
||||
static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, const char *name, enum lh_dbg_t *config ) {
|
||||
|
||||
int val;
|
||||
|
||||
@@ -323,11 +323,11 @@ static bool check_dbg( struct lh_ctx_t *ctx, const struct lh_opt_t *option, cons
|
||||
|
||||
switch ( val ) {
|
||||
|
||||
case DEBUG_LEVEL_NONE :
|
||||
case DEBUG_LEVEL_CRASH :
|
||||
case DEBUG_LEVEL_ERROR :
|
||||
case DEBUG_LEVEL_WARNING :
|
||||
case DEBUG_LEVEL_INFO :
|
||||
case LH_DEBUG_NONE :
|
||||
case LH_DEBUG_CRASH :
|
||||
case LH_DEBUG_ERROR :
|
||||
case LH_DEBUG_WARNING :
|
||||
case LH_DEBUG_INFO :
|
||||
*config = val;
|
||||
return false;
|
||||
}
|
||||
|
@@ -91,7 +91,7 @@ bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep,
|
||||
XX_httplib_fclose( &fp );
|
||||
}
|
||||
|
||||
else httplib_cry( DEBUG_LEVEL_ERROR, ctx, workdata->conn, "%s: cannot open authorization file: %s", __func__, workdata->buf );
|
||||
else httplib_cry( LH_DEBUG_ERROR, ctx, workdata->conn, "%s: cannot open authorization file: %s", __func__, workdata->buf );
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep,
|
||||
* future)
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep,
|
||||
|
||||
if ( workdata->f_domain == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ bool XX_httplib_read_auth_file( const struct lh_ctx_t *ctx, struct file *filep,
|
||||
|
||||
if ( workdata->f_ha1 == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, workdata->conn, "%s: syntax error in authorization file: %s", __func__, workdata->buf );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@@ -96,7 +96,7 @@ void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( conn->data_len < conn->request_len ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: websocket error: data len less than request len, closing connection", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: websocket error: data len less than request len, closing connection", __func__ );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
* connection
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: websocket out of memory; closing connection", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: websocket out of memory; closing connection", __func__ );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -161,7 +161,7 @@ void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( body_len < header_len ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: websocket error: body len less than header len, closing connection", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: websocket error: body len less than header len, closing connection", __func__ );
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ void XX_httplib_read_websocket( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if (error) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: websocket pull failed; closing connection", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: websocket pull failed; closing connection", __func__ );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ int XX_httplib_refresh_trust( const struct lh_ctx_t *ctx, struct lh_con_t *conn
|
||||
|
||||
if ( SSL_CTX_load_verify_locations( ctx->ssl_ctx, ctx->ssl_ca_file, ctx->ssl_ca_path ) != 1 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: SSL_CTX_load_verify_locations error: %s ssl_verify_peer requires setting either ssl_ca_path or ssl_ca_file. Is any of them present in the .conf file?", __func__, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: SSL_CTX_load_verify_locations error: %s ssl_verify_peer requires setting either ssl_ca_path or ssl_ca_file. Is any of them present in the .conf file?", __func__, XX_httplib_ssl_error() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -38,6 +38,6 @@ void XX_httplib_remove_bad_file( const struct lh_ctx_t *ctx, const struct lh_con
|
||||
|
||||
int r = httplib_remove( path );
|
||||
|
||||
if ( r != 0 && ctx != NULL && conn != NULL ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Cannot remove invalid file %s", __func__, path );
|
||||
if ( r != 0 && ctx != NULL && conn != NULL ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Cannot remove invalid file %s", __func__, path );
|
||||
|
||||
} /* XX_httplib_remove_bad_file */
|
||||
|
@@ -87,7 +87,7 @@ int XX_httplib_remove_directory( const struct lh_ctx_t *ctx, struct lh_con_t *co
|
||||
|
||||
if ( ! XX_httplib_stat( ctx, conn, path, & de.file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
ok = 0;
|
||||
}
|
||||
if ( de.file.membuf == NULL ) {
|
||||
|
@@ -68,7 +68,7 @@ int XX_httplib_scan_directory( const struct lh_ctx_t *ctx, struct lh_con_t *conn
|
||||
|
||||
if ( ! XX_httplib_stat( ctx, conn, path, &de.file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: XX_httplib_stat(%s) failed: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
de.file_name = dp->d_name;
|
||||
|
@@ -140,7 +140,7 @@ void XX_httplib_send_file_data( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
#endif
|
||||
if ( offset > 0 && fseeko( filep->fp, offset, SEEK_SET ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: fseeko() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: fseeko() failed: %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
XX_httplib_send_http_error( ctx, conn, 500, "%s", "Error: Unable to access file at requested position." );
|
||||
}
|
||||
|
||||
|
@@ -23,17 +23,17 @@
|
||||
#include "httplib_main.h"
|
||||
|
||||
/*
|
||||
* enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level );
|
||||
* enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level );
|
||||
*
|
||||
* The function httplib_get_debug_level() sets the debug level for a context
|
||||
* The function httplib_set_debug_level() sets the debug level for a context
|
||||
* and returns the previous debug level.
|
||||
*/
|
||||
|
||||
enum debug_level_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum debug_level_t new_level ) {
|
||||
enum lh_dbg_t httplib_set_debug_level( struct lh_ctx_t *ctx, enum lh_dbg_t new_level ) {
|
||||
|
||||
enum debug_level_t prev_level;
|
||||
enum lh_dbg_t prev_level;
|
||||
|
||||
if ( ctx == NULL ) return DEBUG_LEVEL_NONE;
|
||||
if ( ctx == NULL ) return LH_DEBUG_NONE;
|
||||
|
||||
prev_level = ctx->debug_level;
|
||||
ctx->debug_level = new_level;
|
||||
|
@@ -47,7 +47,7 @@ bool XX_httplib_set_gpass_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( path != NULL && ! XX_httplib_stat( ctx, NULL, path, &file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot open %s: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot open %s: %s", __func__, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@@ -140,7 +140,7 @@ void XX_httplib_set_handler_type( struct lh_ctx_t *ctx, const char *uri, int han
|
||||
if ( tmp_rh == NULL ) {
|
||||
|
||||
httplib_unlock_context( ctx );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot create new request handler struct, OOM", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot create new request handler struct, OOM", __func__ );
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ void XX_httplib_set_handler_type( struct lh_ctx_t *ctx, const char *uri, int han
|
||||
|
||||
httplib_unlock_context( ctx );
|
||||
tmp_rh = httplib_free( tmp_rh );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot create new request handler struct, OOM", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot create new request handler struct, OOM", __func__ );
|
||||
|
||||
return;
|
||||
}
|
||||
|
@@ -73,21 +73,21 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( ! parse_port_string( &vec, &so, &ip_version ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: %.*s: invalid port spec (entry %i). Expecting list of: %s", __func__, (int)vec.len, vec.ptr, ports_total, "[IP_ADDRESS:]PORT[s|r]" );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: %.*s: invalid port spec (entry %i). Expecting list of: %s", __func__, (int)vec.len, vec.ptr, ports_total, "[IP_ADDRESS:]PORT[s|r]" );
|
||||
continue;
|
||||
}
|
||||
|
||||
#if !defined(NO_SSL)
|
||||
if ( so.has_ssl && ctx->ssl_ctx == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot add SSL socket (entry %i). Is -ssl_certificate option set?", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot add SSL socket (entry %i). Is -ssl_certificate option set?", __func__, ports_total );
|
||||
continue;
|
||||
}
|
||||
#endif /* ! NO_SLL */
|
||||
|
||||
if ( ( so.sock = socket( so.lsa.sa.sa_family, SOCK_STREAM, 6 ) ) == INVALID_SOCKET ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot create socket (entry %i)", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot create socket (entry %i)", __func__, ports_total );
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
* Set reuse option, but don't abort on errors.
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot set socket option SO_EXCLUSIVEADDRUSE (entry %i)", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot set socket option SO_EXCLUSIVEADDRUSE (entry %i)", __func__, ports_total );
|
||||
}
|
||||
#else /* _WIN32 */
|
||||
if ( setsockopt( so.sock, SOL_SOCKET, SO_REUSEADDR, (SOCK_OPT_TYPE)&on, sizeof(on) ) != 0 ) {
|
||||
@@ -120,7 +120,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
* Set reuse option, but don't abort on errors.
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot set socket option SO_REUSEADDR (entry %i)", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot set socket option SO_REUSEADDR (entry %i)", __func__, ports_total );
|
||||
}
|
||||
#endif /* _WIN32 */
|
||||
|
||||
@@ -134,7 +134,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
* Set IPv6 only option, but don't abort on errors.
|
||||
*/
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot set socket option IPV6_V6ONLY (entry %i)", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot set socket option IPV6_V6ONLY (entry %i)", __func__, ports_total );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( bind( so.sock, &so.lsa.sa, len ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot bind to %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot bind to %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
@@ -158,7 +158,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( bind( so.sock, &so.lsa.sa, len ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot bind to IPv6 %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot bind to IPv6 %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
@@ -166,13 +166,13 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot bind: address family not supported (entry %i)", __func__, ports_total );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot bind: address family not supported (entry %i)", __func__, ports_total );
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( listen( so.sock, SOMAXCONN ) != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot listen to %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot listen to %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, (int)ERRNO, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
@@ -181,7 +181,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
if ( getsockname( so.sock, &(usa.sa), &len ) != 0 || usa.sa.sa_family != so.lsa.sa.sa_family ) {
|
||||
|
||||
int err = (int)ERRNO;
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: call to getsockname failed %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, err, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: call to getsockname failed %.*s: %d (%s)", __func__, (int)vec.len, vec.ptr, err, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
@@ -198,7 +198,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( ptr != NULL ) ctx->listening_sockets = ptr;
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: out of memory on listening sockets", __func__ );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: out of memory on listening sockets", __func__ );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
@@ -209,7 +209,7 @@ int XX_httplib_set_ports_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( pfd != NULL ) ctx->listening_socket_fds = pfd;
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: out of memory on fds", __func__ );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: out of memory on fds", __func__ );
|
||||
closesocket( so.sock );
|
||||
so.sock = INVALID_SOCKET;
|
||||
continue;
|
||||
|
@@ -77,7 +77,7 @@ bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) {
|
||||
ctx->ssl_ctx = SSL_CTX_new( SSLv23_server_method() );
|
||||
if ( ctx->ssl_ctx == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: SSL_CTX_new (server) error: %s", __func__, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: SSL_CTX_new (server) error: %s", __func__, XX_httplib_ssl_error() );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( callback_ret < 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: SSL callback returned error: %i", __func__, callback_ret );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: SSL callback returned error: %i", __func__, callback_ret );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( SSL_CTX_load_verify_locations( ctx->ssl_ctx, ctx->ssl_ca_file, ctx->ssl_ca_path ) != 1 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: SSL_CTX_load_verify_locations error: %s ssl_verify_peer requires setting either ssl_ca_path or ssl_ca_file. Is any of them present in the .conf file?", __func__, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: SSL_CTX_load_verify_locations error: %s ssl_verify_peer requires setting either ssl_ca_path or ssl_ca_file. Is any of them present in the .conf file?", __func__, XX_httplib_ssl_error() );
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -139,7 +139,7 @@ bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( ctx->ssl_verify_paths && SSL_CTX_set_default_verify_paths( ctx->ssl_ctx ) != 1 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: SSL_CTX_set_default_verify_paths error: %s", __func__, XX_httplib_ssl_error());
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: SSL_CTX_set_default_verify_paths error: %s", __func__, XX_httplib_ssl_error());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ bool XX_httplib_set_ssl_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( SSL_CTX_set_cipher_list( ctx->ssl_ctx, ctx->ssl_cipher_list ) != 1 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_WARNING, ctx, NULL, "%s: SSL_CTX_set_cipher_list error: %s", __func__, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_WARNING, ctx, NULL, "%s: SSL_CTX_set_cipher_list error: %s", __func__, XX_httplib_ssl_error() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -56,10 +56,10 @@ bool XX_httplib_set_uid_option( struct lh_ctx_t *ctx ) {
|
||||
|
||||
if ( uid == NULL ) return true;
|
||||
|
||||
if ( (pw = getpwnam(uid)) == NULL ) httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: unknown user [%s]", __func__, uid );
|
||||
else if ( setgid(pw->pw_gid) == -1 ) httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: setgid(%s): %s", __func__, uid, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( setgroups(0, NULL) ) httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: setgroups(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( setuid(pw->pw_uid) == -1 ) httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: setuid(%s): %s", __func__, uid, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
if ( (pw = getpwnam(uid)) == NULL ) httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: unknown user [%s]", __func__, uid );
|
||||
else if ( setgid(pw->pw_gid) == -1 ) httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: setgid(%s): %s", __func__, uid, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( setgroups(0, NULL) ) httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: setgroups(): %s", __func__, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( setuid(pw->pw_uid) == -1 ) httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: setuid(%s): %s", __func__, uid, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else return true;
|
||||
|
||||
return false;
|
||||
|
@@ -133,7 +133,7 @@ pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
|
||||
if ( CreateProcessA( NULL, cmdline, NULL, NULL, TRUE, CREATE_NEW_PROCESS_GROUP, envblk, NULL, &si, &pi ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: CreateProcess(%s): %ld", __func__, cmdline, (long)ERRNO);
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: CreateProcess(%s): %ld", __func__, cmdline, (long)ERRNO);
|
||||
pi.hProcess = (pid_t)-1;
|
||||
|
||||
/*
|
||||
@@ -182,10 +182,10 @@ pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
* Child
|
||||
*/
|
||||
|
||||
if ( chdir( dir ) != 0 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: chdir(%s): %s", __func__, dir, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fdin[0], 0 ) == -1 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: dup2(%d, 0): %s", __func__, fdin[0], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fdout[1], 1 ) == -1 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: dup2(%d, 1): %s", __func__, fdout[1], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fderr[1], 2 ) == -1 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: dup2(%d, 2): %s", __func__, fderr[1], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
if ( chdir( dir ) != 0 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: chdir(%s): %s", __func__, dir, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fdin[0], 0 ) == -1 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: dup2(%d, 0): %s", __func__, fdin[0], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fdout[1], 1 ) == -1 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: dup2(%d, 1): %s", __func__, fdout[1], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else if ( dup2( fderr[1], 2 ) == -1 ) httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: dup2(%d, 2): %s", __func__, fderr[1], httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
else {
|
||||
/*
|
||||
* Keep stderr and stdout in two different pipes.
|
||||
@@ -220,12 +220,12 @@ pid_t XX_httplib_spawn_process( const struct lh_ctx_t *ctx, struct lh_con_t *con
|
||||
if ( interp == NULL ) {
|
||||
|
||||
execle( prog, prog, NULL, envp );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: execle(%s): %s", __func__, prog, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: execle(%s): %s", __func__, prog, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
else {
|
||||
execle( interp, interp, prog, NULL, envp );
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: execle(%s %s): %s", __func__, interp, prog, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: execle(%s %s): %s", __func__, interp, prog, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -98,19 +98,19 @@ static void do_ssi_include( const struct lh_ctx_t *ctx, struct lh_con_t *conn, c
|
||||
}
|
||||
|
||||
else {
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: bad SSI #include: [%s]", __func__, tag );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: bad SSI #include: [%s]", __func__, tag );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( truncated ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: SSI #include path length overflow: [%s]", __func__, tag );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: SSI #include path length overflow: [%s]", __func__, tag );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! XX_httplib_fopen( ctx, conn, path, "rb", &file ) ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: cannot open SSI #include: [%s]: fopen(%s): %s", __func__, tag, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: cannot open SSI #include: [%s]: fopen(%s): %s", __func__, tag, path, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -135,14 +135,14 @@ static void do_ssi_exec( const struct lh_ctx_t *ctx, struct lh_con_t *conn, char
|
||||
|
||||
if ( sscanf(tag, " \"%1023[^\"]\"", cmd) != 1 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: bad SSI #exec: [%s]", __func__, tag );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: bad SSI #exec: [%s]", __func__, tag );
|
||||
}
|
||||
|
||||
else {
|
||||
cmd[1023] = 0;
|
||||
if ( (file.fp = popen( cmd, "r" ) ) == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: cannot SSI #exec: [%s]: %s", __func__, cmd, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: cannot SSI #exec: [%s]: %s", __func__, cmd, httplib_error_string( ERRNO, error_string, ERROR_STRING_LEN ) );
|
||||
}
|
||||
|
||||
else {
|
||||
@@ -175,7 +175,7 @@ static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, co
|
||||
|
||||
if ( include_level > ctx->ssi_include_depth ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: SSI #include level is too deep (%s)", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: SSI #include level is too deep (%s)", __func__, path );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, co
|
||||
do_ssi_exec( ctx, conn, buf+9 );
|
||||
}
|
||||
#endif /* !NO_POPEN */
|
||||
else httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: %s: unknown SSI command: \"%s\"", __func__, path, buf );
|
||||
else httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: %s: unknown SSI command: \"%s\"", __func__, path, buf );
|
||||
}
|
||||
|
||||
len = 0;
|
||||
@@ -232,7 +232,7 @@ static void send_ssi_file( const struct lh_ctx_t *ctx, struct lh_con_t *conn, co
|
||||
|
||||
else if ( len == (int)sizeof(buf) - 2 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: %s: SSI tag is too large", __func__, path );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: %s: SSI tag is too large", __func__, path );
|
||||
len = 0;
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,7 @@ int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ) {
|
||||
|
||||
if ( SSL_CTX_use_certificate_file( ctx->ssl_ctx, pem, 1 ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot open certificate file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot open certificate file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -53,19 +53,19 @@ int XX_httplib_ssl_use_pem_file( const struct lh_ctx_t *ctx, const char *pem ) {
|
||||
|
||||
if ( SSL_CTX_use_PrivateKey_file( ctx->ssl_ctx, pem, 1 ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot open private key file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot open private key file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( SSL_CTX_check_private_key( ctx->ssl_ctx ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: certificate and private key do not match: %s", __func__, pem );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: certificate and private key do not match: %s", __func__, pem );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ( SSL_CTX_use_certificate_chain_file( ctx->ssl_ctx, pem ) == 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot use certificate chain file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot use certificate chain file %s: %s", __func__, pem, XX_httplib_ssl_error() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -99,7 +99,7 @@ struct lh_ctx_t *httplib_start( const struct lh_clb_t *callbacks, void *user_dat
|
||||
*/
|
||||
|
||||
httplib_atomic_dec( & XX_httplib_sTlsInit );
|
||||
httplib_cry( DEBUG_LEVEL_CRASH, ctx, NULL, "%s: cannot initialize thread local storage", __func__ );
|
||||
httplib_cry( LH_DEBUG_CRASH, ctx, NULL, "%s: cannot initialize thread local storage", __func__ );
|
||||
ctx = httplib_free( ctx );
|
||||
|
||||
return NULL;
|
||||
@@ -230,7 +230,7 @@ struct lh_ctx_t *httplib_start( const struct lh_clb_t *callbacks, void *user_dat
|
||||
|
||||
wta = httplib_free( wta );
|
||||
|
||||
if ( i > 0 ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot start worker thread %i: error %ld", __func__, i+1, (long)ERRNO );
|
||||
if ( i > 0 ) httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot start worker thread %i: error %ld", __func__, i+1, (long)ERRNO );
|
||||
|
||||
else return XX_httplib_abort_start( ctx, "Cannot create worker threads: error %ld", (long)ERRNO );
|
||||
|
||||
|
@@ -49,7 +49,7 @@ int64_t httplib_store_body( const struct lh_ctx_t *ctx, struct lh_con_t *conn, c
|
||||
|
||||
if ( conn->consumed_content != 0 ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: Contents already consumed", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: Contents already consumed", __func__ );
|
||||
return -11;
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ void XX_httplib_vsnprintf( const struct lh_ctx_t *ctx, const struct lh_con_t *co
|
||||
|
||||
else {
|
||||
if ( truncated != NULL ) *truncated = true;
|
||||
if ( ctx != NULL && conn != NULL) httplib_cry( DEBUG_LEVEL_WARNING, ctx, conn, "%s: truncating vsnprintf buffer: [%.*s]", __func__, (int)((buflen > 200) ? 200 : (buflen - 1)), buf );
|
||||
if ( ctx != NULL && conn != NULL) httplib_cry( LH_DEBUG_WARNING, ctx, conn, "%s: truncating vsnprintf buffer: [%.*s]", __func__, (int)((buflen > 200) ? 200 : (buflen - 1)), buf );
|
||||
n = (int)buflen - 1;
|
||||
}
|
||||
buf[n] = '\0';
|
||||
|
@@ -52,7 +52,7 @@ int httplib_websocket_client_write( const struct lh_ctx_t *ctx, struct lh_con_t
|
||||
|
||||
if ( masked_data == NULL ) {
|
||||
|
||||
httplib_cry( DEBUG_LEVEL_ERROR, ctx, conn, "%s: cannot allocate buffer for masked websocket response: Out of memory", __func__ );
|
||||
httplib_cry( LH_DEBUG_ERROR, ctx, conn, "%s: cannot allocate buffer for masked websocket response: Out of memory", __func__ );
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@@ -89,7 +89,7 @@ static void *worker_thread_run( struct worker_thread_args *thread_args ) {
|
||||
if ( ctx->callbacks.init_thread != NULL ) ctx->callbacks.init_thread( ctx, 1 ); /* call init_thread for a worker thread (type 1) */
|
||||
|
||||
conn = httplib_calloc( 1, sizeof(*conn) + MAX_REQUEST_SIZE );
|
||||
if ( conn == NULL ) httplib_cry( DEBUG_LEVEL_ERROR, ctx, NULL, "%s: cannot create new connection struct, OOM", __func__ );
|
||||
if ( conn == NULL ) httplib_cry( LH_DEBUG_ERROR, ctx, NULL, "%s: cannot create new connection struct, OOM", __func__ );
|
||||
|
||||
else {
|
||||
httplib_pthread_setspecific( XX_httplib_sTlsKey, &tls );
|
||||
|
Reference in New Issue
Block a user