Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/feature/WWM-81' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
idealflower-k committed Nov 29, 2023
2 parents 4711eb9 + 6a43040 commit bc35271
Show file tree
Hide file tree
Showing 180 changed files with 5,244 additions and 315 deletions.
Empty file added .session/for_session
Empty file.
Empty file added .users/for_users
Empty file.
Empty file.
Binary file added YoupiBanane/cgi_tester.cgi
Binary file not shown.
Empty file added YoupiBanane/index.html
Empty file.
Empty file added YoupiBanane/nop/other.pouic
Empty file.
Empty file.
Empty file added YoupiBanane/put_test/index.html
Empty file.
Binary file added YoupiBanane/tester/tester
Binary file not shown.
27 changes: 27 additions & 0 deletions YoupiBanane/tester/testerdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Test GET http://localhost:1234/
Test POST http://localhost:1234/ with a size of 0
Test HEAD http://localhost:1234/
Test GET http://localhost:1234/directory
Test GET http://localhost:1234/directory/youpi.bad_extension
Test GET http://localhost:1234/directory/youpi.bla
Test GET Expected 404 on http://localhost:1234/directory/oulalala
Test GET http://localhost:1234/directory/nop
Test GET http://localhost:1234/directory/nop/
Test GET http://localhost:1234/directory/nop/other.pouic
Test GET Expected 404 on http://localhost:1234/directory/nop/other.pouac
Test GET Expected 404 on http://localhost:1234/directory/Yeah
Test GET http://localhost:1234/directory/Yeah/not_happy.bad_extension
Test Put http://localhost:1234/put_test/file_should_exist_after with a size of 1000
Test Put http://localhost:1234/put_test/file_should_exist_after with a size of 10000000
Test POST http://localhost:1234/directory/youpi.bla with a size of 100000000
Test POST http://localhost:1234/directory/youpla.bla with a size of 100000000
Test POST http://localhost:1234/directory/youpi.bla with a size of 100000 with special headers
Test POST http://localhost:1234/post_body with a size of 0
Test POST http://localhost:1234/post_body with a size of 100
Test POST http://localhost:1234/post_body with a size of 200
Test POST http://localhost:1234/post_body with a size of 101
Test multiple workers(5) doing multiple times(15): GET on /
Test multiple workers(20) doing multiple times(5000): GET on /
Test multiple workers(128) doing multiple times(50): GET on /directory/nop
Test multiple workers(20) doing multiple times(5): Put on /put_test/multiple_same with size 1000000
Test multiple workers(20) doing multiple times(5): Post on /directory/youpi.bla with size 100000000
Empty file added YoupiBanane/youpi.bad_extension
Empty file.
Empty file added YoupiBanane/youpi.bla
Empty file.
50 changes: 50 additions & 0 deletions config/test/YoupiBanane.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
http {
error_page 424 404 /4242.html;
include /config/test/mime.types;
sendfile off;
keepalive_timeout 300;
default_type application/octet-stream;
error_log /log/error.log debug;
server {
listen 1113;
server_name WebWaveMaker;
error_page 424 404 /4242.html;
error_page 500 502 503 504 /50x.html;
client_max_body_size 1m;
root /Users/jgo/Programming/devjgo/webserv/YoupiBanane/;
location / {
root /Users/jgo/Programming/devjgo/webserv/YoupiBanane/;
limit_except GET;
index /index.html;
autoindex on;
}

location /put_test/ {
root /Users/jgo/Programming/devjgo/webserv/YoupiBanane/put_test/;
limit_except PUT;
index /index.html;
autoindex off;
}

location /post_body/ {
root /Users/jgo/Programming/devjgo/webserv/YoupiBanane/;
limit_except POST;
index /tmp;
autoindex off;
}

location /directory/ {
root /Users/jgo/Programming/devjgo/webserv/YoupiBanane/;
limit_except GET POST;
index /youpi.bad_extension;
autoindex off;
}

location /.bla/ {
root /Users/jgo/Programming/devjgo/webserv/;
limit_except POST;
autoindex off;
cgi_index /cgi_tester.cgi;
}
}
}
45 changes: 24 additions & 21 deletions config/test/default.conf
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
http {
sendfile off;
keepalive_timeout 4242;
default_type 4242/4242;
client_max_body_size 2m;
error_page 424 404 /4242.html;
error_page 502 503 504 /50x.html;
error_log ./log/error.log debug;
server {
listen 4242;
server_name localhost;
root /var/www/html;
location {
root /var/www/empty;
include /config/test/mime.types;
sendfile off;
keepalive_timeout 30;
default_type application/octet-stream;
client_max_body_size 1m;
error_log /log/error.log debug;
server {
listen 4244;
server_name WebWaveMaker;
error_page 424 404 413 /4242.html;
error_page 500 502 503 504 /50x.html;
root /Users/jgo/Programming/devjgo/webserv/var/www/;
location / {
root /Users/jgo/Programming/devjgo/webserv/var/www/empty/;
limit_except GET POST PUT HEAD;
}
location /location {
root /var/www/location1;
location /location/ {
return 301 /;
}
}
server {
listen 2424;
server_name outside;
root /var/www/4242;
location /location2 {
root /var/www/location2;
location /delete/ {
root /Users/jgo/Programming/devjgo/webserv/var/www/delete/;
}
location /.bla/ {
root /Users/jgo/Programming/devjgo/webserv/var/www/;
limit_except GET POST;
cgi_index /cgi_tester;
}
}
}
84 changes: 84 additions & 0 deletions config/test/mime.types
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
text/html html;
text/html htm;
text/html shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg;
image/jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin;
application/octet-stream exe;
application/octet-stream dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
19 changes: 16 additions & 3 deletions inc/const.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,22 @@

#define CRLF "\r\n"
#define RNRN "\r\n\r\n"
#define CONTENT_LENGTH "Content-Length"
#define CONTENT_TYPE "Content-Type"
#define TRANSFER_ENCODING "Transfer-Encoding"
#define SET_COOKIE "Set-Cookie"
#define COOKIE "Cookie"
#define MULTIPART_FORM_DATA "multipart/form-data"

#ifndef BUFFER_SIZE
#define BUFFER_SIZE 4096
#endif
#define BUFFER_SIZE 100000
#define FT 42
#define CRLF_LEN 2

#define FD_ERROR -1
#define FD_LISTING -2
#define FD_ZERO_ -3
#define SYSTEMCALL_ERROR -1

#define SESSION_EXPIRED_TIME 60

#endif
69 changes: 64 additions & 5 deletions inc/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,76 @@ enum Directives {
SERVER_NAME, // server, string default : empty
ROOT, // server, location string default : specific to directory
AUTOINDEX, // server, location on : true, off : false default : false
INDEX, // server, location string default : index.html
LIMIT_EXCEPT // server, location std::vector<enum HttpMethods> default : {GET, POST, DELETE, PUT}
INDEX, // server, location std::vector<string> default : index.html
LIMIT_EXCEPT, // server, location std::vector<enum HttpMethods> default : {GET, POST, DELETE, PUT}
RETURN, // server, location int, string default : empty
CGI_INDEX, // server, location std::vector<string> default : empty
};

enum HTTP_STATUS {
// status error
MY_ERROR = -1,
// 200
OK = 200,
CREATED = 201,
ACCEPTED = 202,
NO_CONTENT = 204, // body가 없는 경우
PARTIAL_CONTENT = 206,
// 300
MULTIPLE_CHOICES = 300,
MOVED_PERMANENTLY = 301,
FOUND = 302,
SEE_OTHER = 303,
NOT_MODIFIED = 304,
TEMPORARY_REDIRECT = 307,
PERMANENT_REDIRECT = 308,

// 400
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
FORBIDDEN = 403,
NOT_FOUND = 404,
METHOD_NOT_ALLOWED = 405,
REQUEST_TIMEOUT = 408,
CONFLICT = 409,
GONE = 410,
LENGTH_REQUIRED = 411,
PAYLOAD_TOO_LARGE = 413,
UNSUPPORTED_MEDIA_TYPE = 415,
TOO_MANY_REQUESTS = 429,

// 500
INTERNAL_SERVER_ERROR = 500,
NOT_IMPLEMENTED = 501,
BAD_GATEWAY = 502,
SERVICE_UNAVAILABLE = 503,
GATEWAY_TIMEOUT = 504,
HTTP_VERSION_NOT_SUPPORTED = 505
};

enum LogLevels { LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG };

enum HttpMethods { GET, POST, DELETE, PUT };
enum HttpMethods { GET, HEAD, POST, DELETE, PUT, UNKNOWN };

enum AsyncState { PENDING, RESOLVE, TERMINATE, ACCEPT, NONE };

enum AsyncState { PENDING, RESOLVE, TERMINATE, ACCEPT };
enum HttpMessageState {
DONE,
HTTP_ERROR,
START_LINE,
HEADER,
BODY,
CHUNKED_FIRST,
CHUNKED,
CHUNKED_DONE,
CHUNKED_ERROR,
LONG_FIRST,
LONG_BODY,
LONG_BODY_DONE,
LONG_BODY_ERROR
};

enum HttpMessageState { DONE, ERROR, START_LINE, HEADER, BODY };
enum FileMode { MODE_ERROR, MODE_FILE, MODE_DIRECTORY };

enum EventType {
EVENT_READ = -1,
Expand Down
1 change: 1 addition & 0 deletions inc/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
typedef int errno_t;
typedef int handle_t;
typedef int fd_t;
typedef std::string sessionId_t;

#endif
8 changes: 8 additions & 0 deletions src/AConfig/AConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,11 @@ ConfigValue AConfig::addMedVecValue(const std::vector<HttpMethods>& value) {
ConfigValue AConfig::addStrVecValue(const std::vector<std::string>& value) {
return ConfigValue(value);
}

bool AConfig::isDirective(Directives method) const {
std::map<Directives, ConfigValue>::const_iterator it = _directives.find(method);
if (it == _directives.end()) {
return false; // 지시어를 찾을 수 없음
}
return true;
}
10 changes: 10 additions & 0 deletions src/AConfig/AConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ class AConfig {
* @return A ConfigValue object containing the directive value.
*/
virtual ConfigValue getDirectives(Directives method) const = 0;

/**
* @brief Check if the given method is a directive.
*
* This function checks if the given method is a directive.
*
* @param method The method to check.
* @return true if the method is a directive, false otherwise.
*/
bool isDirective(Directives method) const;
};

#endif // ACONFIG_HPP
Loading

0 comments on commit bc35271

Please sign in to comment.