mucked about with Telnet

This commit is contained in:
Me
2022-08-13 03:01:41 +02:00
parent a69273b88e
commit 3495ff19a8
6 changed files with 61 additions and 8 deletions

View File

@@ -21,15 +21,21 @@ server {
location /upload { location /upload {
root ./www/test/; root ./www/test/;
index submit_form.html; index submit_form.html;
upload_dir ./www/uploaded/; # upload_dir ./www/uploaded/;
cgi_ext php; # cgi_ext php;
} }
location /uploaded { location /uploaded {
autoindex on; # autoindex on;
root ./www/uploaded/; root ./www/uploaded/;
upload_dir ./www/uploaded/;
} }
# location /srcs/cgi-bin/ {
# root ./srcs/cgi-bin/;
# allow_methods POST;
# cgi_ext php;
# }
location /list { location /list {
autoindex on; autoindex on;

View File

@@ -10,8 +10,9 @@
# echo("File was uploaded successfully!"); # echo("File was uploaded successfully!");
// this part needs to be grabed from POST uri // this part needs to be grabed from POST uri
//$target_dir = "./www/uploaded/"; $target_dir = "./www/uploaded/";
$target_dir = $_POST["upload_dir"]; //$target_dir = $_POST["upload_dir"];
//$target_dir = $_GET["upload_dir"];
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1; $uploadOk = 1;
$fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); $fileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));

View File

@@ -114,7 +114,7 @@ void Webserv::_autoindex(Client *client, const std::string &path)
struct dirent *ent; struct dirent *ent;
// std::cout << "location root: " << client->assigned_location->root << " location path: " // std::cout << "location root: " << client->assigned_location->root << " location path: "
<< client->assigned_location->path << '\n'; // << 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)

37
telnet_test.sh Executable file
View File

@@ -0,0 +1,37 @@
#! /bin/bash
# no idea what we're doing here...
PORT=80
METHOD="GET"
PATH="/"
HOST="localhost $PORT"
START="open $HOST"
L1="$METHOD $PATH HTTP/1.1"
run()
{
# echo "this is a test"
# $TEL_START
# spaw telnet localhost $PORT
echo $START
echo
# sleep 1
echo $L1
echo "Host: $HOST"
echo
echo
}
#echo $START
run

8
telnet_test2.sh Executable file
View File

@@ -0,0 +1,8 @@
#! /usr/bin/expect
set timeout 20
set Host "localhost 80"
spawn telnet $Host

View File

@@ -7,8 +7,9 @@
<h1 style="text-align:center">Webserv in Test</h1> <h1 style="text-align:center">Webserv in Test</h1>
<hr> <hr>
<p style="text-align:center">Time to submit something:</p> <p style="text-align:center">Time to submit something:</p>
<form action="./srcs/cgi-bin/upload_file.php" method="post"> <!-- <form action="./srcs/cgi-bin/upload_file.php" method="post" enctype="multipart/form-data"> -->
<input type="hidden" name="upload_dir" value="./www/uploaded/"> <form action="/uploaded" method="post" enctype="multipart/form-data">
<!-- <input type="hidden" name="upload_dir" value="./www/uploaded/"> -->
<input type="file" id="fileToUpload" name="myFile"> <input type="file" id="fileToUpload" name="myFile">
<input type="submit" value="Upload File"> <input type="submit" value="Upload File">
</form> </form>