mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-29 05:17:59 +03:00
fix: segv
This commit is contained in:
@@ -1,18 +1,18 @@
|
|||||||
[[server]]
|
[[server]]
|
||||||
name = "pohek1.org"
|
name = "pohek1.org"
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1" # check inet_addr()
|
||||||
port = 8080
|
port = 8080 # check num, (0, 65536)
|
||||||
body_size_limit = 10000000
|
body_size_limit = 10000000 #(pofig and > 0)
|
||||||
[server.error_page]
|
[server.error_page]
|
||||||
403 = "www/errorFolder/index2.html"
|
"404" = "www/errorFolder/error_404.html" # throw exception if not string
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "/"
|
location = "/" # mandatory
|
||||||
root = "www/"
|
root = "www/" # check valid
|
||||||
methods = ["GET", "POST", "DELETE"]
|
methods = ["GET", "POST", "DELETE"]
|
||||||
autoindex = true
|
autoindex = true #check if bool
|
||||||
directory_file = "index.html"
|
directory_file = "index.html"
|
||||||
upload_accept = true
|
upload_accept = true #throw exception if not bool
|
||||||
upload_dir = "/var/www/html/upload"
|
upload_dir = "www/upload" # check valid
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "/images"
|
location = "/images"
|
||||||
root = "www/images"
|
root = "www/images"
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
autoindex = true
|
autoindex = true
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "/images/168.png"
|
location = "/images/168.png"
|
||||||
redirect = ["301", "http://127.0.0.1:8080/168.png"]
|
redirect = ["301", "http://127.0.0.1:8080/168.png"] #throw exception if no array, or more 2 elem, or elem is not str
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "/errorFolder/images/168.png"
|
location = "/errorFolder/images/168.png"
|
||||||
redirect = ["301", "http://127.0.0.1:8080/168.png"]
|
redirect = ["301", "http://127.0.0.1:8080/168.png"]
|
||||||
@@ -32,20 +32,16 @@
|
|||||||
location = "*.png"
|
location = "*.png"
|
||||||
root = "www/images/pngImg"
|
root = "www/images/pngImg"
|
||||||
methods = ["GET"]
|
methods = ["GET"]
|
||||||
[[server.location]]
|
|
||||||
location = "*.ico"
|
|
||||||
root = "www/images/icoImg"
|
|
||||||
methods = ["GET"]
|
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "/errorFolder"
|
location = "/errorFolder"
|
||||||
root = "www/errorFolder"
|
root = "www/errorFolder"
|
||||||
methods = ["GET", "POST"]
|
methods = ["GET", "POST"]
|
||||||
autoindex = false
|
autoindex = true
|
||||||
[[server.location]]
|
[[server.location]]
|
||||||
location = "*.php"
|
location = "*.php"
|
||||||
root = "www/script"
|
root = "www/script"
|
||||||
autoindex = false
|
autoindex = false
|
||||||
cgi_pass = "/usr/bin/php-cgi"
|
cgi_pass = "/usr/bin/php-cgi" #check valid
|
||||||
[[server]]
|
[[server]]
|
||||||
name = "pohek2.org"
|
name = "pohek2.org"
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
@@ -63,7 +59,7 @@
|
|||||||
autoindex = true
|
autoindex = true
|
||||||
directory_file = "index.html"
|
directory_file = "index.html"
|
||||||
upload_accept = false
|
upload_accept = false
|
||||||
upload_dir = "/var/www/html/upload"
|
upload_dir = "www/upload"
|
||||||
[[server]]
|
[[server]]
|
||||||
name = "localhost"
|
name = "localhost"
|
||||||
host = "127.0.0.1"
|
host = "127.0.0.1"
|
||||||
@@ -81,4 +77,4 @@
|
|||||||
autoindex = true
|
autoindex = true
|
||||||
directory_file = "index.html"
|
directory_file = "index.html"
|
||||||
upload_accept = false
|
upload_accept = false
|
||||||
upload_dir = "/var/www/html/upload"
|
upload_dir = "www/upload"
|
||||||
|
|||||||
@@ -135,7 +135,11 @@ location *Config::getLocation(std::vector<location *> &arr, std::string &URI)
|
|||||||
{
|
{
|
||||||
tmp = *it;
|
tmp = *it;
|
||||||
if (tmp->location == "/")
|
if (tmp->location == "/")
|
||||||
|
{
|
||||||
|
tmp = new location;
|
||||||
|
copyLocation(tmp, *it);
|
||||||
return (tmp);
|
return (tmp);
|
||||||
|
}
|
||||||
it++;
|
it++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ std::string Response::getFullURI(void)
|
|||||||
else
|
else
|
||||||
ret = tmp;
|
ret = tmp;
|
||||||
|
|
||||||
|
DBOUT << PINK << "location " << _location->location << ENDL;
|
||||||
|
DBOUT << PINK << "fullURI " << ret << ENDL;
|
||||||
return (ret);
|
return (ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,14 +417,6 @@ void Response::methodPost(void)
|
|||||||
_body.erase(_body.begin(), _body.begin() + pos + 4);
|
_body.erase(_body.begin(), _body.begin() + pos + 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::ofstream outfile(_fullURI.c_str(), std::ios::out | std::ios::binary);
|
|
||||||
|
|
||||||
outfile.write(_request.getBody().data(), _request.getBody().size());
|
|
||||||
outfile.close();
|
|
||||||
_code = 204;
|
|
||||||
}
|
|
||||||
setHeaderBlocks();
|
setHeaderBlocks();
|
||||||
generateHeader();
|
generateHeader();
|
||||||
DBOUT << GREEN << "POST method called" << ENDL;
|
DBOUT << GREEN << "POST method called" << ENDL;
|
||||||
|
|||||||
Reference in New Issue
Block a user