a few small fixes here and there, more telnet tests, starting Siege load testing
This commit is contained in:
@@ -63,8 +63,12 @@ server {
|
|||||||
root ./Tester/www/test/;
|
root ./Tester/www/test/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /stylesheet {
|
||||||
|
root ./stylesheet/;
|
||||||
|
}
|
||||||
|
|
||||||
location /test/index1.html {
|
location /test/index1.html {
|
||||||
root ./Tester/www/test/;
|
root ./Tester/www/test/index1.html;
|
||||||
index index1.html subdex.html;
|
index index1.html subdex.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,14 +76,9 @@ server {
|
|||||||
redirect 301 https://berniesanders.com/404/;
|
redirect 301 https://berniesanders.com/404/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /stylesheet/ {
|
|
||||||
# root ./www/../;
|
|
||||||
root ./styelsheet/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /test/something.html {
|
location /test/something.html {
|
||||||
# allow_methods DELETE;
|
# allow_methods DELETE;
|
||||||
root ./Tester/www/test/;
|
root ./Tester/www/test/something.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /test/test_deeper/ {
|
location /test/test_deeper/ {
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
test_name="Header Test"
|
test_name="Header Test"
|
||||||
|
|
||||||
config_file="test1.config"
|
config_file="./Tester/test1.config"
|
||||||
port=4040
|
port=4040
|
||||||
host="localhost"
|
host="localhost"
|
||||||
|
|
||||||
@@ -41,10 +41,10 @@ run_this_test()
|
|||||||
{
|
{
|
||||||
echo "----- $test_name -----"
|
echo "----- $test_name -----"
|
||||||
echo -e "$_RED$request$_END"
|
echo -e "$_RED$request$_END"
|
||||||
} >> telnet.out
|
} >> telnet.log
|
||||||
echo -e "$request"
|
echo -e "$request"
|
||||||
sleep 1
|
sleep 1
|
||||||
echo -e "\n\n" >> telnet.out
|
echo -e "\n\n" >> telnet.log
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
test_name="Method Test"
|
test_name="Method Test"
|
||||||
|
|
||||||
config_file="test1.config"
|
config_file="./Tester/test1.config"
|
||||||
port=4040
|
port=4040
|
||||||
host="localhost"
|
host="localhost"
|
||||||
|
|
||||||
@@ -41,10 +41,10 @@ run_this_test()
|
|||||||
{
|
{
|
||||||
echo "----- $test_name -----"
|
echo "----- $test_name -----"
|
||||||
echo -e "$_RED$request$_END"
|
echo -e "$_RED$request$_END"
|
||||||
} >> telnet.out
|
} >> telnet.log
|
||||||
echo -e "$request"
|
echo -e "$request"
|
||||||
sleep 1
|
sleep 1
|
||||||
echo -e "\n\n" >> telnet.out
|
echo -e "\n\n" >> telnet.log
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
test_name="Path Test"
|
test_name="Path Test"
|
||||||
|
|
||||||
config_file="test1.config"
|
config_file="./Tester/test1.config"
|
||||||
port=4040
|
port=4040
|
||||||
host="localhost"
|
host="localhost"
|
||||||
|
|
||||||
@@ -31,7 +31,6 @@ run_this_test()
|
|||||||
echo "----- $test_name -----"
|
echo "----- $test_name -----"
|
||||||
echo -e "$_RED$request$_END"
|
echo -e "$_RED$request$_END"
|
||||||
} >> telnet.log
|
} >> telnet.log
|
||||||
# echo -e "$request" > compare.txt >> telnet.out
|
|
||||||
echo -e "$request"
|
echo -e "$request"
|
||||||
sleep 1
|
sleep 1
|
||||||
echo -e "\n" >> telnet.log
|
echo -e "\n" >> telnet.log
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
test_name="Template test all good"
|
test_name="Template test all good"
|
||||||
|
|
||||||
config_file="default.config"
|
config_file="./Tester/test1.config"
|
||||||
port=4040
|
port=4040
|
||||||
host="localhost"
|
host="localhost"
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ run_this_test()
|
|||||||
{
|
{
|
||||||
echo "----- $test_name -----"
|
echo "----- $test_name -----"
|
||||||
echo -e "$_RED$request$_END"
|
echo -e "$_RED$request$_END"
|
||||||
} >> telnet.out
|
} >> telnet.log
|
||||||
# } &>> test.log
|
# } &>> test.log
|
||||||
# } 2>>&1
|
# } 2>>&1
|
||||||
# } &>> /dev/stdout
|
# } &>> /dev/stdout
|
||||||
@@ -47,7 +47,7 @@ run_this_test()
|
|||||||
# } > /dev/stdout
|
# } > /dev/stdout
|
||||||
# echo -e "\n\n\n------\n\n\n" >> telnet.out
|
# echo -e "\n\n\n------\n\n\n" >> telnet.out
|
||||||
# echo -e "\n\n\n------\n\n\n" &> /dev/stdout
|
# echo -e "\n\n\n------\n\n\n" &> /dev/stdout
|
||||||
echo -e "\n\n" >> telnet.out
|
echo -e "\n\n" >> telnet.log
|
||||||
# echo -e "\n\n------\n\n" >> telnet.out
|
# echo -e "\n\n------\n\n" >> telnet.out
|
||||||
# echo -e "\n------\n" > /dev/stdout
|
# echo -e "\n------\n" > /dev/stdout
|
||||||
# run_a_test
|
# run_a_test
|
||||||
|
|||||||
74
Tester/test_valid_uri.sh
Normal file
74
Tester/test_valid_uri.sh
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
test_name="Valid URIs Test"
|
||||||
|
|
||||||
|
config_file="./Tester/test1.config"
|
||||||
|
port=4040
|
||||||
|
host="localhost"
|
||||||
|
|
||||||
|
paths=("/" "/stylesheet/style.css" "/test/something.html" "/test/something.html/" "/test/" "/list" "/hilarious_404" "/redirect") # you can add many
|
||||||
|
#paths=("/") # you can add many
|
||||||
|
#methods=("GET" "POST" "DELETE")
|
||||||
|
methods=("GET")
|
||||||
|
httpz=("HTTP/1.1")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
l1="${methods[0]} ${paths[0]} ${httpz[0]}"
|
||||||
|
|
||||||
|
header="Host: $host"
|
||||||
|
body=
|
||||||
|
|
||||||
|
|
||||||
|
run_this_test()
|
||||||
|
{
|
||||||
|
|
||||||
|
for i in "${paths[@]}"
|
||||||
|
do
|
||||||
|
l1="${methods[0]} $i ${httpz[0]}"
|
||||||
|
request="$l1\n$header\n$body\n"
|
||||||
|
{
|
||||||
|
echo "----- $test_name -----"
|
||||||
|
echo -e "$_RED$request$_END"
|
||||||
|
} >> telnet.log
|
||||||
|
echo -e "$request"
|
||||||
|
sleep 1
|
||||||
|
echo -e "\n" >> telnet.log
|
||||||
|
done
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# expected result...
|
||||||
|
|
||||||
|
|
||||||
|
files=()
|
||||||
|
|
||||||
|
file="expected_valid_uri_test.txt"
|
||||||
|
files+=("expected_valid_files_test.txt")
|
||||||
|
#files+=("expected_path_root_test.txt")
|
||||||
|
#files+=("expected_path_testnoslash_test.txt")
|
||||||
|
#files+=("expected_path_testslash_test.txt")
|
||||||
|
#files+=("expected_path_list_test.txt")
|
||||||
|
#files+=("expected_path_badlist_test.txt")
|
||||||
|
#files+=("expected_path_wrong_test.txt")
|
||||||
|
|
||||||
|
|
||||||
|
#local_expected_test_file=$file
|
||||||
|
local_expected_test_files=()
|
||||||
|
test_path=""
|
||||||
|
|
||||||
|
add_path()
|
||||||
|
{
|
||||||
|
for i in "${files[@]}"
|
||||||
|
do
|
||||||
|
local_expected_test_files+=("$test_path$i")
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#add_path
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -2,9 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Webserv test index</title>
|
<title>Webserv test index</title>
|
||||||
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
|
|
||||||
<link rel="stylesheet" href="/stylesheet/style.css">
|
<link rel="stylesheet" href="/stylesheet/style.css">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Webserv Test Index</h1>
|
<h1>Webserv Test Index</h1>
|
||||||
|
|||||||
76
compare.txt
76
compare.txt
@@ -21,19 +21,26 @@ Content-Length: 193
|
|||||||
HTTP/1.1 200 OK
|
HTTP/1.1 200 OK
|
||||||
Server: Webserv/0.1
|
Server: Webserv/0.1
|
||||||
Connection: keep-alive
|
Connection: keep-alive
|
||||||
|
Content-Type: text/css; charset=UTF-8
|
||||||
|
Content-Length: 43
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: red;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Server: Webserv/0.1
|
||||||
|
Connection: keep-alive
|
||||||
Content-Type: text/html; charset=UTF-8
|
Content-Type: text/html; charset=UTF-8
|
||||||
Content-Length: 290
|
Content-Length: 207
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Webserv test index</title>
|
<title>Webserv test Something</title>
|
||||||
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
|
|
||||||
<link rel="stylesheet" href="/stylesheet/style.css">
|
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Webserv Test Index</h1>
|
<h1 style="text-align:center">Webserv Test Something</h1>
|
||||||
<hr>
|
<hr>
|
||||||
<p style="text-align:center">(˚3˚)</p>
|
<p style="text-align:center">(˚3˚)</p>
|
||||||
</body>
|
</body>
|
||||||
@@ -42,15 +49,30 @@ HTTP/1.1 200 OK
|
|||||||
Server: Webserv/0.1
|
Server: Webserv/0.1
|
||||||
Connection: keep-alive
|
Connection: keep-alive
|
||||||
Content-Type: text/html; charset=UTF-8
|
Content-Type: text/html; charset=UTF-8
|
||||||
Content-Length: 290
|
Content-Length: 207
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Webserv test Something</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="text-align:center">Webserv Test Something</h1>
|
||||||
|
<hr>
|
||||||
|
<p style="text-align:center">(˚3˚)</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
HTTP/1.1 200 OK
|
||||||
|
Server: Webserv/0.1
|
||||||
|
Connection: keep-alive
|
||||||
|
Content-Type: text/html; charset=UTF-8
|
||||||
|
Content-Length: 227
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Webserv test index</title>
|
<title>Webserv test index</title>
|
||||||
<!-- <link rel="stylesheet" href="stylesheet/style.css"> -->
|
|
||||||
<link rel="stylesheet" href="/stylesheet/style.css">
|
<link rel="stylesheet" href="/stylesheet/style.css">
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Webserv Test Index</h1>
|
<h1>Webserv Test Index</h1>
|
||||||
@@ -58,7 +80,7 @@ Content-Length: 290
|
|||||||
<p style="text-align:center">(˚3˚)</p>
|
<p style="text-align:center">(˚3˚)</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
HTTP/1.1
|
HTTP/1.1 200 OK
|
||||||
Server: Webserv/0.1
|
Server: Webserv/0.1
|
||||||
Connection: keep-alive
|
Connection: keep-alive
|
||||||
Content-Type: text/html; charset=UTF-8
|
Content-Type: text/html; charset=UTF-8
|
||||||
@@ -80,37 +102,13 @@ Content-Length: 1277
|
|||||||
<a style="font-size:1.5em" href="/list/rfc2119.html">rfc2119.html</a>
|
<a style="font-size:1.5em" href="/list/rfc2119.html">rfc2119.html</a>
|
||||||
<a style="font-size:1.5em" href="/list/error_pages">error_pages</a>
|
<a style="font-size:1.5em" href="/list/error_pages">error_pages</a>
|
||||||
<a style="font-size:1.5em" href="/list/rfc2119_files">rfc2119_files</a>
|
<a style="font-size:1.5em" href="/list/rfc2119_files">rfc2119_files</a>
|
||||||
</pre><hr></body></html>HTTP/1.1 404 Not Found
|
</pre><hr></body></html>HTTP/1.1 301 Moved Permanently
|
||||||
|
Location: https://berniesanders.com/404/
|
||||||
|
|
||||||
Server: Webserv/0.1
|
Server: Webserv/0.1
|
||||||
Connection: keep-alive
|
Connection: keep-alive
|
||||||
Content-Type: text/html; charset=UTF-8
|
HTTP/1.1 307 Temporary Redirect
|
||||||
Content-Length: 210
|
Location: https://fr.wikipedia.org/wiki/Ketchup
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>404 Not Found</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 style="text-align:center">Check it UP 404 Not Found</h1>
|
|
||||||
<hr>
|
|
||||||
<p style=\"text-align:center\">Le Webserv/0.1</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
HTTP/1.1 404 Not Found
|
|
||||||
Server: Webserv/0.1
|
Server: Webserv/0.1
|
||||||
Connection: keep-alive
|
Connection: keep-alive
|
||||||
Content-Type: text/html; charset=UTF-8
|
|
||||||
Content-Length: 210
|
|
||||||
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>404 Not Found</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 style="text-align:center">Check it UP 404 Not Found</h1>
|
|
||||||
<hr>
|
|
||||||
<p style=\"text-align:center\">Le Webserv/0.1</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
@@ -63,8 +63,12 @@ server {
|
|||||||
root ./www/test/;
|
root ./www/test/;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location /stylesheet {
|
||||||
|
root ./stylesheet/;
|
||||||
|
}
|
||||||
|
|
||||||
location /test/index1.html {
|
location /test/index1.html {
|
||||||
root ./www/test/;
|
root ./www/test/index1.html;
|
||||||
index index1.html subdex.html;
|
index index1.html subdex.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,14 +76,9 @@ server {
|
|||||||
redirect 301 https://berniesanders.com/404/;
|
redirect 301 https://berniesanders.com/404/;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /stylesheet/ {
|
|
||||||
# root ./www/../;
|
|
||||||
root ./styelsheet/;
|
|
||||||
}
|
|
||||||
|
|
||||||
location /test/something.html {
|
location /test/something.html {
|
||||||
# allow_methods DELETE;
|
# allow_methods DELETE;
|
||||||
root ./www/test/;
|
root ./www/test/something.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /test/test_deeper/ {
|
location /test/test_deeper/ {
|
||||||
|
|||||||
11
main_test.sh
11
main_test.sh
@@ -21,7 +21,8 @@ _END='\033[0m'
|
|||||||
|
|
||||||
|
|
||||||
#test_file_names=("test_template.sh" "test_header.sh" "test_path.sh")
|
#test_file_names=("test_template.sh" "test_header.sh" "test_path.sh")
|
||||||
test_file_names=("test_method.sh" "test_header.sh" "test_path.sh")
|
#test_file_names=("test_method.sh" "test_header.sh" "test_path.sh")
|
||||||
|
test_file_names=("test_valid_uri.sh")
|
||||||
#test_file_names=("test_path.sh")
|
#test_file_names=("test_path.sh")
|
||||||
|
|
||||||
test_files=()
|
test_files=()
|
||||||
@@ -103,10 +104,10 @@ test_all()
|
|||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# if [ "$arg" != "diff" ];
|
if [ "$arg" = "" ];
|
||||||
# then
|
then
|
||||||
# cat telnet.log
|
cat telnet.log
|
||||||
# fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,6 +361,8 @@ void Client::_parse_request_target( std::string target )
|
|||||||
else
|
else
|
||||||
_request.query = "";
|
_request.query = "";
|
||||||
_request.abs_path = target.substr(0, pos);
|
_request.abs_path = target.substr(0, pos);
|
||||||
|
if (_request.abs_path[_request.abs_path.size() - 1] == '/')
|
||||||
|
_request.abs_path.erase(_request.abs_path.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Client::_parse_request_fields()
|
void Client::_parse_request_fields()
|
||||||
|
|||||||
@@ -50,14 +50,6 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
|||||||
&& it_l->path.size() > 1)
|
&& it_l->path.size() > 1)
|
||||||
it_l->path.erase(it_l->path.size() - 1);
|
it_l->path.erase(it_l->path.size() - 1);
|
||||||
|
|
||||||
std::vector<LocationConfig>::const_iterator tmp = it_l + 1;
|
|
||||||
while (tmp != it->locations.end())
|
|
||||||
{
|
|
||||||
if (it_l->path == tmp->path)
|
|
||||||
throw std::invalid_argument("Duplicate locations in config file");
|
|
||||||
++tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it_l->root == "")
|
if (it_l->root == "")
|
||||||
it_l->root = it->root;
|
it_l->root = it->root;
|
||||||
|
|
||||||
@@ -71,6 +63,20 @@ void ConfigParser::_post_processing(std::vector<ServerConfig> *servers)
|
|||||||
|
|
||||||
++it_l;
|
++it_l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
it_l = it->locations.begin();
|
||||||
|
while (it_l != it->locations.end())
|
||||||
|
{
|
||||||
|
std::vector<LocationConfig>::const_iterator tmp = it_l + 1;
|
||||||
|
while (tmp != it->locations.end())
|
||||||
|
{
|
||||||
|
if (it_l->path == tmp->path)
|
||||||
|
throw std::invalid_argument("Duplicate locations in config file");
|
||||||
|
++tmp;
|
||||||
|
}
|
||||||
|
++it_l;
|
||||||
|
}
|
||||||
|
|
||||||
std::sort(it->locations.begin(), it->locations.end());
|
std::sort(it->locations.begin(), it->locations.end());
|
||||||
std::reverse(it->locations.begin(), it->locations.end());
|
std::reverse(it->locations.begin(), it->locations.end());
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ void Webserv::_get(Client *client, std::string &path)
|
|||||||
{
|
{
|
||||||
path.append(client->assigned_location->index[i]);
|
path.append(client->assigned_location->index[i]);
|
||||||
_get_file(client, path);
|
_get_file(client, path);
|
||||||
|
std::cerr << "Added an index\n"; //debug
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,16 +89,10 @@ void Webserv::_autoindex(Client *client, const std::string &path)
|
|||||||
{
|
{
|
||||||
std::cout << "_autoindex()\n";
|
std::cout << "_autoindex()\n";
|
||||||
|
|
||||||
// std::cout << "client target: " << client->get_rq_target() << '\n';
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string dir_list;
|
std::string dir_list;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
struct dirent *ent;
|
struct dirent *ent;
|
||||||
|
|
||||||
// std::cout << "location root: " << client->assigned_location->root << " location path: " << client->assigned_location->path << '\n';
|
|
||||||
|
|
||||||
// std::cout << "Path in auto is: " << path << '\n';
|
// std::cout << "Path in auto is: " << path << '\n';
|
||||||
if ( (dir = opendir(path.c_str()) ) != NULL)
|
if ( (dir = opendir(path.c_str()) ) != NULL)
|
||||||
{
|
{
|
||||||
@@ -106,20 +101,19 @@ void Webserv::_autoindex(Client *client, const std::string &path)
|
|||||||
dir_list.append(AUTOINDEX_MID1);
|
dir_list.append(AUTOINDEX_MID1);
|
||||||
dir_list.append(path);
|
dir_list.append(path);
|
||||||
dir_list.append(AUTOINDEX_MID2);
|
dir_list.append(AUTOINDEX_MID2);
|
||||||
/* print all the files and directories within directory */
|
|
||||||
while ((ent = readdir (dir)) != NULL)
|
while ((ent = readdir (dir)) != NULL)
|
||||||
{
|
{
|
||||||
// std::cout << "ent: " << ent->d_name << '\n';
|
|
||||||
if (strcmp(".", ent->d_name) == 0)
|
if (strcmp(".", ent->d_name) == 0)
|
||||||
continue ;
|
continue ;
|
||||||
dir_list.append("<a style=\"font-size:1.5em\" href=\"");
|
dir_list.append("<a style=\"font-size:1.5em\" href=\"");
|
||||||
// dir_list.append(client->get_rq_target());
|
|
||||||
dir_list.append(client->get_rq_abs_path());
|
dir_list.append(client->get_rq_abs_path());
|
||||||
if (dir_list[dir_list.size() - 1] != '/')
|
if (dir_list[dir_list.size() - 1] != '/')
|
||||||
dir_list.push_back('/');
|
dir_list.push_back('/');
|
||||||
dir_list.append(ent->d_name);
|
dir_list.append(ent->d_name);
|
||||||
dir_list.append("\">");
|
dir_list.append("\">");
|
||||||
dir_list.append(ent->d_name);
|
dir_list.append(ent->d_name);
|
||||||
|
if (ent->d_type == DT_DIR)
|
||||||
|
dir_list.append("/");
|
||||||
dir_list.append("</a>");
|
dir_list.append("</a>");
|
||||||
dir_list.append("\n");
|
dir_list.append("\n");
|
||||||
}
|
}
|
||||||
@@ -131,15 +125,14 @@ void Webserv::_autoindex(Client *client, const std::string &path)
|
|||||||
// <a href="/test/test_deeper/..">..</a>
|
// <a href="/test/test_deeper/..">..</a>
|
||||||
|
|
||||||
dir_list.append(AUTOINDEX_END);
|
dir_list.append(AUTOINDEX_END);
|
||||||
// std::cout << "\n\n" << dir_list << '\n';
|
|
||||||
closedir (dir);
|
closedir (dir);
|
||||||
|
client->status = 200;
|
||||||
_append_body(client, dir_list, "html");
|
_append_body(client, dir_list, "html");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// in theory not possible cuz we already checked...
|
client->status = 500;
|
||||||
std::cerr << "could not open dir\n";
|
perror("could not open dir");
|
||||||
// throw?
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ void Webserv::_construct_response(Client *client)
|
|||||||
void Webserv::_process_method(Client *client, std::string &path)
|
void Webserv::_process_method(Client *client, std::string &path)
|
||||||
{
|
{
|
||||||
std::cerr << "allow_methods = " << http_methods_to_str(client->assigned_location->allow_methods) << "\n"; // debug
|
std::cerr << "allow_methods = " << http_methods_to_str(client->assigned_location->allow_methods) << "\n"; // debug
|
||||||
|
std::cerr << "Path again: " << path << '\n'; // debug
|
||||||
|
|
||||||
switch (client->get_rq_method())
|
switch (client->get_rq_method())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user