Compare commits

..

2 Commits

2 changed files with 24 additions and 6 deletions

View File

@ -381,12 +381,20 @@ static void _http_add_body_bytes(tf_http_connection_t* connection, const void* d
}; };
connection->request = request; connection->request = request;
if (!connection->http->is_shutting_down)
{
tf_http_request_ref(request); tf_http_request_ref(request);
tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "http"); tf_trace_begin(connection->http->trace, connection->trace_name ? connection->trace_name : "http");
connection->callback(request); connection->callback(request);
tf_trace_end(connection->http->trace); tf_trace_end(connection->http->trace);
tf_http_request_unref(request); tf_http_request_unref(request);
} }
else
{
const char* k_payload = tf_http_status_text(503);
tf_http_respond(request, 503, NULL, 0, k_payload, strlen(k_payload));
}
}
} }
} }
@ -784,6 +792,8 @@ const char* tf_http_status_text(int status)
return "File not found"; return "File not found";
case 500: case 500:
return "Internal server error"; return "Internal server error";
case 503:
return "Service Unavailable";
default: default:
return "Unknown"; return "Unknown";
} }

View File

@ -11,6 +11,7 @@
#include "backtrace.h" #include "backtrace.h"
#include "sqlite3.h" #include "sqlite3.h"
#include "unzip.h"
#include <getopt.h> #include <getopt.h>
#include <stdlib.h> #include <stdlib.h>
@ -412,11 +413,18 @@ static int _tf_command_run(const char* file, int argc, char* argv[])
.http_port = 12345, .http_port = 12345,
.https_port = 12346, .https_port = 12346,
.ssb_port = 8008, .ssb_port = 8008,
.zip = file,
.db_path = k_db_path_default, .db_path = k_db_path_default,
}; };
bool show_usage = false; bool show_usage = false;
/* Check if the executable has data attached. */
unzFile zip = unzOpen(file);
if (zip)
{
args.zip = file;
unzClose(zip);
}
while (!show_usage) while (!show_usage)
{ {
static const struct option k_options[] = { static const struct option k_options[] = {