mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-12 12:42:50 +08:00
http_error callback
Allow user to display status code errors
This commit is contained in:
parent
1cb094e059
commit
2efc5d9fce
@ -915,6 +915,8 @@ static void send_http_error(struct mg_connection *conn, int status,
|
||||
int len = 0;
|
||||
|
||||
conn->status_code = status;
|
||||
if (conn->ctx->callbacks.http_error == NULL ||
|
||||
conn->ctx->callbacks.http_error(conn, status)) {
|
||||
buf[0] = '\0';
|
||||
|
||||
// Errors 1xx, 204 and 304 MUST NOT send a body
|
||||
@ -934,6 +936,7 @@ static void send_http_error(struct mg_connection *conn, int status,
|
||||
suggest_connection_header(conn));
|
||||
conn->num_bytes_sent += mg_printf(conn, "%s", buf);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && !defined(__SYMBIAN32__)
|
||||
static int pthread_mutex_init(pthread_mutex_t *mutex, void *unused) {
|
||||
|
@ -67,6 +67,7 @@ struct mg_callbacks {
|
||||
const char *path, size_t *data_len);
|
||||
void (*init_lua)(struct mg_connection *, void *lua_context);
|
||||
void (*upload)(struct mg_connection *, const char *file_name);
|
||||
int (*http_error)(struct mg_connection *, int status);
|
||||
};
|
||||
|
||||
// Start web server.
|
||||
|
Loading…
Reference in New Issue
Block a user