Skip to content

Commit e799f9a

Browse files
author
Tom Hinchliff
committed
Lets a go!
1 parent d0f7ed2 commit e799f9a

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

actions.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "actions.h"
1313

1414
static const char *HTTP_OK_RESPONSE =
15-
"HTTP/1.1 200 OK\r\n" // Status-Line
15+
"HTTP/1.1 204 OK\r\n" // Status-Line
1616
"Connection: close\r\n" // Headers
1717
"\r\n"; // Content break
1818

@@ -42,10 +42,10 @@ void generic_action(int client_socket, HTTP_REQUEST req)
4242
strlen(HTTP_OK_RESPONSE), 0);
4343
}
4444

45+
// A generic 204, let the client know that we accepted the message, but there
46+
// is no content.
4547
void ok_action(int client_socket, HTTP_REQUEST req)
4648
{
47-
DEBUG_LOG("Ok action!\n");
48-
4949
if (req.body)
5050
{
5151
DEBUG_LOG("We have a body\n%s\n", req.body);
@@ -56,6 +56,7 @@ void ok_action(int client_socket, HTTP_REQUEST req)
5656
strlen(HTTP_OK_TEXT_RESPONSE), 0);
5757
}
5858

59+
// Error processing or no match, simply a 404.
5960
void not_found_action(int client_socket, HTTP_REQUEST req)
6061
{
6162
DEBUG_LOG("404 action!!\n");
@@ -81,9 +82,6 @@ void github_action(int client_socket, HTTP_REQUEST req)
8182
int pid = fork();
8283
if (pid == 0)
8384
{
84-
DEBUG_LOG("Child process!\n");
85-
close(1);
86-
close(2);
8785
execl("/bin/sh", "sh", script_path, NULL);
8886
// If exec fails we terminate the process.
8987
kill(getpid(), SIGKILL);
@@ -93,8 +91,7 @@ void github_action(int client_socket, HTTP_REQUEST req)
9391
{
9492
DEBUG_LOG("Error: file %s not found\n", script_path);
9593
}
96-
DEBUG_LOG("Child should not get here....\n");
9794
// Action data.
98-
send(client_socket, HTTP_OK_TEXT_RESPONSE,
99-
strlen(HTTP_OK_TEXT_RESPONSE), 0);
95+
send(client_socket, HTTP_OK_RESPONSE,
96+
strlen(HTTP_OK_RESPONSE), 0);
10097
}

0 commit comments

Comments
 (0)