summaryrefslogtreecommitdiffstats
path: root/sources/ogAdmServer.cpp
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2019-08-28 16:52:36 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2019-08-28 17:22:12 +0200
commit15685e618fa33b23655bd86f9ea7f9571a570ca2 (patch)
tree5284819eb24900b64b47413610f8956084b4086e /sources/ogAdmServer.cpp
parent84a25639b36644a20591ad0b141476c6c7d261a6 (diff)
#915 add og_server_internal_error()
This function sends a 500 HTTP error to client.
Diffstat (limited to 'sources/ogAdmServer.cpp')
-rw-r--r--sources/ogAdmServer.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/sources/ogAdmServer.cpp b/sources/ogAdmServer.cpp
index 8362796..0c3396e 100644
--- a/sources/ogAdmServer.cpp
+++ b/sources/ogAdmServer.cpp
@@ -3955,6 +3955,16 @@ static int og_client_not_authorized(struct og_client *cli)
return -1;
}
+static int og_server_internal_error(struct og_client *cli)
+{
+ char buf[] = "HTTP/1.1 500 Internal Server Error\r\n"
+ "Content-Length: 0\r\n\r\n";
+
+ send(og_client_socket(cli), buf, strlen(buf), 0);
+
+ return -1;
+}
+
#define OG_MSG_RESPONSE_MAXLEN 65536
static int og_client_ok(struct og_client *cli, char *buf_reply)
@@ -3965,11 +3975,8 @@ static int og_client_ok(struct og_client *cli, char *buf_reply)
len = snprintf(buf, sizeof(buf),
"HTTP/1.1 200 OK\r\nContent-Length: %ld\r\n\r\n%s",
strlen(buf_reply), buf_reply);
- if (len >= (int)sizeof(buf)) {
- snprintf(buf, sizeof(buf),
- "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n");
- err = -1;
- }
+ if (len >= (int)sizeof(buf))
+ err = og_server_internal_error(cli);
send(og_client_socket(cli), buf, strlen(buf), 0);