Skip to content

Commit

Permalink
Merge pull request #43 from saladuit/mergeFix
Browse files Browse the repository at this point in the history
Fixes for merge CGI & ConfigImplementation
  • Loading branch information
saladuit authored May 15, 2024
2 parents 5dfddb6 + e24517d commit 112624b
Show file tree
Hide file tree
Showing 16 changed files with 206 additions and 170 deletions.
60 changes: 29 additions & 31 deletions config/default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ server {
allowed_methods GET; # [M - O] Define a list of accepted HTTP methods for the route; GET/POST/DELETE ; Default: GET
autoindex on; # [B - O] Turn on or off directory listing; on; Default: off
}

}

server {
Expand All @@ -39,7 +38,8 @@ server {
}

location /python/ {
alias /cgi/python/; # already defined;
allowed_methods GET POST;
alias /data/python/; # already defined;
cgi on; # [1 - O] Set a Path to where the CGI can find the Binary; [A-Za-z_/.]* ; Default: [EMPTY]
}

Expand All @@ -48,45 +48,43 @@ server {
allowed_methods GET POST;
autoindex on;
}

location /png/ {
alias /data/images/png/;
allowed_methods GET POST;
autoindex off;
}

location /images/jpg/ {
alias /data/upload/images/jpg/;
allowed_methods GET POST;
autoindex off;
}

location /upload/ {
alias /data/upload/;
allowed_methods POST DELETE;
}

location /removed_folder/ {
alias /data/www/;
allowed_methods GET;
return /images/coffee-resized.jpeg ; # [1 - O] Reroute a directory to another URL; URL ; Default: []
}
# location /png/ {
# alias /data/images/png/;
# allowed_methods GET POST;
# autoindex off;
# }
#
# location /images/jpg/ {
# alias /data/upload/images/jpg/;
# allowed_methods GET POST;
# autoindex off;
# }
#
# location /upload/ {
# alias /data/upload/;
# allowed_methods POST DELETE;
# }
#
# location /removed_folder/ {
# alias /data/www/;
# allowed_methods GET;
# return /images/coffee-resized.jpeg ; # [1 - O] Reroute a directory to another URL; URL ; Default: []
# }
}

#TODO: all Settings still need implementation into the Webserver
# [ ] SetDefaultValues for configfile.
# [ ] ServerBlock:
# [ ] listen; //
# [ ] server_name; // should go over the Clients/HTTPServers after
# [x] ServerBlock:
# [x] listen; //
# [x] server_name; // should go over the Clients/HTTPServers after
# // the request is recieved and see which serverSettings block is relevant to the request;
# [x] error_dir; // should search this direcotry to find the relevant error file [e.g. 404.html];
# [x] client_max_body_size; // limits the size of the client Request, returning 413 when it exceeds this value;
# [ ] Location Block:
# [x] Location Block:
# [x] alias; // should do a fitted preppend on the path in URI;
# [x] index; // file return of the request just specifies this directory ;
# [x] autoindex; // Automaticly should create a Index file that shows an overview of the direcotry;
# [x] allowed_methods; // should check if the HTTP Method is allowed in this location;
# [ ] cgi; // is a boolean that shows if the directory is a CGI and the value is the path to the executable;
# [x] cgi; // is a boolean that shows if the directory is a CGI and the value is the path to the executable;
# [x] return; //
# [x] HTTPerrorpagegenerator // method that can generate a simple ERROR page to the _response.
#
File renamed without changes.
29 changes: 0 additions & 29 deletions data/www/autoindexresult.html

This file was deleted.

3 changes: 3 additions & 0 deletions include/Client.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef CLIENT_HPP
#define CLIENT_HPP

#include "AutoIndexGenerator.hpp"
#include "CGI.hpp"
#include "FileManager.hpp"
#include "HTTPRequest.hpp"
Expand Down Expand Up @@ -46,6 +47,8 @@ class Client
ClientState _state;
int _serverToCgiFd[2];
int _cgiToServerFd[2];

void checkCGI(const std::string &request_target, HTTPMethod method);
};

#endif
3 changes: 1 addition & 2 deletions include/FileManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class FileManager
bool _autoindex;
size_t _bytes_sent;

std::string applyLocationSettings(const std::string &request_target,
HTTPMethod method);
std::string applyLocationSettings(const std::string &request_target);

public:
FileManager();
Expand Down
5 changes: 3 additions & 2 deletions include/LocationSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class LocationSettings
const std::string &getIndex() const;
const std::string &getAllowedMethods() const;
const std::string &getRedirect() const;
bool getAutoIndex() const;
const bool &getCGI() const;
const bool &getAutoIndex() const;

// resolves:

Expand All @@ -50,7 +51,7 @@ class LocationSettings
std::string _alias;
std::string _index;
std::string _allowed_methods;
std::string _cgi_path;
bool _cgi;
std::string _redirect;
bool _auto_index;

Expand Down
4 changes: 3 additions & 1 deletion include/Socket.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef SOCKET_HPP
#define SOCKET_HPP

#include <arpa/inet.h>
#include <netinet/in.h>
#include <string>
#include <sys/socket.h>

// MAX_PENDING_CONNECTION SHOULDN'T BE 1
// WHY 10? WE CAN ALSO SET IT ON 1024, THAT'S
// WHY 10? WE CAN ALSO SET IT ON 1024, THAT'S
// MORE SAFE, CONCERNING THE AVAILABILITY (siege -b)
#define MAX_PENDING_CONNECTIONS 10

Expand Down
Loading

0 comments on commit 112624b

Please sign in to comment.