small fixes
This commit is contained in:
10
cmd/server.c
10
cmd/server.c
@@ -39,6 +39,7 @@ int parseHTTPRequest(unsigned char *buffer, struct HTTPRequest *r) {
|
||||
int contentCheck = 0;
|
||||
unsigned char *checkLine = calloc(1000, sizeof(unsigned char));
|
||||
unsigned char *logLine = malloc(sizeof(unsigned char));
|
||||
char * varCheck;
|
||||
|
||||
// Creating empty requestBody
|
||||
r->requestBody = calloc(8, sizeof(char));
|
||||
@@ -61,8 +62,11 @@ int parseHTTPRequest(unsigned char *buffer, struct HTTPRequest *r) {
|
||||
strcpy(r->requestType, token);
|
||||
// Grabbing HTTP Request Dir
|
||||
token = strtok(NULL, " ");
|
||||
r->requestDir = malloc(strlen(token));
|
||||
strcpy(r->requestDir, token);
|
||||
varCheck = strchr(token, '?');
|
||||
if (varCheck != NULL) {
|
||||
*varCheck = ' ';
|
||||
}
|
||||
sscanf(token, "%ms %ms", &r->requestDir, &r->requestVars);
|
||||
// Grabbing HTTP Request Version
|
||||
token = strtok(NULL, "");
|
||||
token[strlen(token) - 1] = '\0'; // Fixing version end char
|
||||
@@ -233,7 +237,7 @@ int handleRequest(unsigned char buffer[], int socket, SSL *ssl) {
|
||||
if (checkerr != 0) { // Checking for HTTP parsing error
|
||||
if (checkerr == -1) {
|
||||
printDebug("Error reading request, returning empty 500");
|
||||
return500Request(socket, ssl);
|
||||
return return500Request(socket, ssl);
|
||||
} else {
|
||||
printDebug("Error parsing, returning 501");
|
||||
return return501Request(socket, ssl);
|
||||
|
||||
Reference in New Issue
Block a user