PHP Error handling

This commit is contained in:
2018-06-04 22:53:32 +02:00
parent 8e510d6c41
commit 7a889d4722

View File

@ -12,6 +12,7 @@
#include <fstream>
#include <openssl/md5.h>
#include <cstring>
#include <fcntl.h>
#include "network/Socket.h"
#include "network/http/HttpRequest.h"
@ -114,6 +115,7 @@ string getETag(string filename) {
#include <iostream>
#include <wait.h>
long getPosition(std::string str, char c, int occurence) {
int tempOccur = 0;
int num = 0;
@ -292,12 +294,22 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
}
fclose(file);
int c = fgetc(pipes.stdout);
if (c == -1) {
// No Data -> Error
req.respond((statuscode == 0) ? 500 : statuscode);
statuscode = -1;
} else {
ungetc(c, pipes.stdout);
}
file = pipes.stdout;
}
if (statuscode != -1) {
statuscode = (statuscode == 0) ? 200 : statuscode;
bool compress = path.isStatic() && type.find("text/") == 0 && req.isExistingField("Accept-Encoding") &&
bool compress = path.isStatic() && type.find("text/") == 0 &&
req.isExistingField("Accept-Encoding") &&
req.getField("Accept-Encoding").find("deflate") != string::npos;
if (compress) {
@ -342,6 +354,7 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
}
}
}
}
fclose(file);
if (childpid > 0) {
waitpid(childpid, nullptr, 0);