Revert "Add http_error callback"

This reverts commit 27fe9c8f01.
This commit is contained in:
Joe Mucchiello 2013-02-10 15:50:20 -05:00
parent 27fe9c8f01
commit 1cb094e059
2 changed files with 5475 additions and 5479 deletions

View File

@ -915,27 +915,24 @@ static void send_http_error(struct mg_connection *conn, int status,
int len = 0; int len = 0;
conn->status_code = status; conn->status_code = status;
if (conn->ctx->callbacks.http_error == NULL || buf[0] = '\0';
conn->ctx->callbacks.http_error(conn, status)) {
buf[0] = '\0';
// Errors 1xx, 204 and 304 MUST NOT send a body // Errors 1xx, 204 and 304 MUST NOT send a body
if (status > 199 && status != 204 && status != 304) { if (status > 199 && status != 204 && status != 304) {
len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason); len = mg_snprintf(conn, buf, sizeof(buf), "Error %d: %s", status, reason);
buf[len++] = '\n'; buf[len++] = '\n';
va_start(ap, fmt); va_start(ap, fmt);
len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap); len += mg_vsnprintf(conn, buf + len, sizeof(buf) - len, fmt, ap);
va_end(ap); va_end(ap);
}
DEBUG_TRACE(("[%s]", buf));
mg_printf(conn, "HTTP/1.1 %d %s\r\n"
"Content-Length: %d\r\n"
"Connection: %s\r\n\r\n", status, reason, len,
suggest_connection_header(conn));
conn->num_bytes_sent += mg_printf(conn, "%s", buf);
} }
DEBUG_TRACE(("[%s]", buf));
mg_printf(conn, "HTTP/1.1 %d %s\r\n"
"Content-Length: %d\r\n"
"Connection: %s\r\n\r\n", status, reason, len,
suggest_connection_header(conn));
conn->num_bytes_sent += mg_printf(conn, "%s", buf);
} }
#if defined(_WIN32) && !defined(__SYMBIAN32__) #if defined(_WIN32) && !defined(__SYMBIAN32__)

View File

@ -67,7 +67,6 @@ struct mg_callbacks {
const char *path, size_t *data_len); const char *path, size_t *data_len);
void (*init_lua)(struct mg_connection *, void *lua_context); void (*init_lua)(struct mg_connection *, void *lua_context);
void (*upload)(struct mg_connection *, const char *file_name); void (*upload)(struct mg_connection *, const char *file_name);
int (*http_error)(struct mg_connection *, int status);
}; };
// Start web server. // Start web server.