-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
161 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
server { | ||
listen 4343 | ||
server_name localhost test.com | ||
root www | ||
index index.html | ||
error_page 404 /404.html | ||
error_page 405 /405.html | ||
max_client_body_size 400 | ||
listen 4343; | ||
root www/site0; | ||
index index.html; | ||
location / { | ||
allow GET POST DELETE | ||
index index.html | ||
allow GET; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
server { | ||
listen 4343; | ||
server_name localhost test.com; | ||
root www/; | ||
cgi .py /usr/bin/python2.7; | ||
cgi .php ./www/cgi-bin/php-cgi; | ||
cgi .php ./cgis/php-cgi; | ||
root www; | ||
index index.html; | ||
error_page 405 /405.html; | ||
max_client_body_size 4096; | ||
|
||
max_client_body_size 10; | ||
location / { | ||
allow GET HEAD POST DELETE; | ||
allow GET POST DELETE; | ||
root first; | ||
# index page.html; | ||
} | ||
location /first/ { | ||
allow GET HEAD; | ||
location /one/ { | ||
allow GET DELETE POST; | ||
autoindex 1; | ||
# index page.html; | ||
} | ||
location /demo/ { | ||
allow GET HEAD POST DELETE; | ||
index index.html; | ||
root /site1; | ||
} | ||
# location /first/second/ { | ||
# allow GET; | ||
# # index page.html; | ||
# } | ||
location /blabla/ { | ||
location /two { | ||
allow GET; | ||
# index page.html; | ||
root site2/; | ||
index hello.html; | ||
} | ||
location /three { | ||
allow GET POST DELETE; | ||
root site3/; | ||
index index.html; | ||
} | ||
location /first_redirect/ { | ||
} | ||
|
||
server { | ||
listen 6969; | ||
root www; | ||
index index.html; | ||
max_client_body_size 10; | ||
location / { | ||
allow GET; | ||
root first/; | ||
index page.html; | ||
autoindex 1; | ||
} | ||
location /form/ { | ||
allow GET POST; | ||
return 301 http://localhost/form.html; | ||
# index page.html; | ||
location /data/ { | ||
allow GET DELETE; | ||
autoindex 1; | ||
root uploads; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
server { | ||
listen 4344; | ||
server_name foo; | ||
root www/first; | ||
index page.html; | ||
cgi .php ./cgis/php-cgi; | ||
location / { | ||
allow GET; | ||
} | ||
} | ||
|
||
server { | ||
listen 4343; | ||
server_name foo; | ||
root www/site1; | ||
index index.html; | ||
cgi .php ./cgis/php-cgi; | ||
location / { | ||
allow GET; | ||
} | ||
} | ||
|
||
server { | ||
listen 4343; | ||
server_name bar; | ||
root www/site2; | ||
index index.html; | ||
cgi .php ./cgis/php-cgi; | ||
location / { | ||
allow GET; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
server { | ||
listen 6969; | ||
cgi .php /usr/bin/php-cgi; | ||
cgi .py /usr/bin/python; | ||
root www; | ||
index index.html; | ||
max_client_body_size -1; | ||
location / { | ||
allow GET; | ||
autoindex 0; | ||
index trick.html; | ||
} | ||
location /php { | ||
allow GET POST; | ||
autoindex 1; | ||
root /site1; | ||
} | ||
location /py { | ||
allow GET POST; | ||
autoindex 1; | ||
root /site2; | ||
} | ||
location /downloads { | ||
allow GET DELETE; | ||
autoindex 1; | ||
root /uploads; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: edal--ce <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/10/26 12:07:35 by edal--ce #+# #+# */ | ||
/* Updated: 2022/01/20 14:57:24 by edal--ce ### ########.fr */ | ||
/* Updated: 2022/01/21 17:41:57 by edal--ce ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -73,40 +73,19 @@ void Client::set_response(void) | |
|
||
if (req && req->get_type() == "POST" && req->get_s_header("Content-Type").find("multipart") != string::npos) | ||
{ | ||
// DEBUG("We are in the mode"); | ||
// DEBUG("|" << req->get_s_header("Body")<< "|"); | ||
if (req->get_s_header("Body").size() != static_cast<unsigned int>(atoi(req->get_s_header("Content-Length").c_str()))) | ||
{ | ||
// DEBUG("rcb is " << rec_buffer); | ||
// req->get_s_header("Body") += rec_buffer; | ||
// rec_buffer.clear(); | ||
// Log("NEED TO GET MORE DATA"); | ||
_status = 4; | ||
// DEBUG("We are in the WTF"); | ||
return; | ||
} | ||
else | ||
_status = 1; | ||
} | ||
|
||
unsigned int ctlen = atoi(req->get_s_header("Content-Length").c_str()); | ||
// DEBUG("CTLEN IS " << ctlen); | ||
// DEBUG("CODE IS " << req->get_code()); | ||
|
||
|
||
req->body_size_ok(ctlen); | ||
// todo: | ||
// if (req && ctlen > req->get_max_body() ) | ||
// { | ||
// DEBUG("DATA IS TOO BIG"); | ||
// r | ||
// req->code = 413; | ||
|
||
// // exit(0); | ||
// } | ||
// DEBUG("MAX BODY OK"); | ||
// if (req->get_s_header("Content-Length")) | ||
|
||
req->set_filepath(); | ||
int operation_status = req->get_file_status(_file_fd); | ||
DEBUG("OPSTAT IS " << operation_status); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/07/28 14:04:40 by edal--ce #+# #+# */ | ||
/* Updated: 2022/01/19 15:50:08 by hthomas ### ########.fr */ | ||
/* Updated: 2022/01/21 16:15:37 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -28,7 +28,7 @@ bool Location::is_valid(string &error) const | |
list<string> allow = get_allow(); | ||
if (allow.size() == 0) | ||
error = (get_path() + " location: allowed method(s) are not set"); | ||
if (get_location_root() == "") | ||
if (get_root() == "") | ||
error = (get_path() + " location: location_root is not set"); | ||
return (error.length() == 0); | ||
} | ||
|
@@ -58,7 +58,7 @@ string Location::get_HTTP_redirection() const | |
return (this->HTTP_redirection); | ||
} | ||
|
||
string Location::get_location_root() const | ||
string Location::get_root() const | ||
{ | ||
return (this->location_root); | ||
} | ||
|
@@ -102,7 +102,7 @@ void Location::set_HTTP_redirection(const string HTTP_redirection) | |
this->HTTP_redirection = HTTP_redirection; | ||
} | ||
|
||
void Location::set_location_root(const string location_root) | ||
void Location::set_root(const string location_root) | ||
{ | ||
this->location_root = location_root; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
/* By: hthomas <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/11/05 16:55:59 by hthomas #+# #+# */ | ||
/* Updated: 2022/01/20 18:05:02 by hthomas ### ########.fr */ | ||
/* Updated: 2022/01/21 16:15:37 by hthomas ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
|
@@ -84,7 +84,7 @@ Location parse_location(const vector<string> &config, size_t *line_count, Server | |
tmp = '/' + tmp; | ||
if (tmp.size() > 1 && tmp[tmp.size() - 1] == '/') | ||
tmp.resize(tmp.size() - 1); | ||
location.set_location_root(tmp); | ||
location.set_root(tmp); | ||
DEBUG("\t\t\t" << tmp); | ||
} | ||
else if (line[0] == "index") | ||
|
@@ -118,8 +118,8 @@ Location parse_location(const vector<string> &config, size_t *line_count, Server | |
exit(EXIT_FAILURE); | ||
} | ||
DEBUG("\t}"); | ||
if (location.get_location_root().size() == 0) | ||
location.set_location_root(location.get_path()); | ||
if (location.get_root().size() == 0) | ||
location.set_root(location.get_path()); | ||
location.set_server(server); | ||
return location; | ||
} | ||
|
Oops, something went wrong.