mirror of
https://github.com/3lswear/webserv.git
synced 2025-10-28 21:07:59 +03:00
Merge remote-tracking branch 'origin/roman' into fara
This commit is contained in:
29
config/tester.toml
Normal file
29
config/tester.toml
Normal file
@@ -0,0 +1,29 @@
|
||||
[[server]]
|
||||
name = "pohek1.org"
|
||||
host = "127.0.0.1"
|
||||
port = 8080
|
||||
[[server.location]]
|
||||
location = "/"
|
||||
root = "www/tester/"
|
||||
methods = ["GET"]
|
||||
autoindex = true
|
||||
directory_file = "index.html"
|
||||
[[server.location]]
|
||||
location = "/put_test/*"
|
||||
root = "www/tester/"
|
||||
methods = ["PUT]"]
|
||||
autoindex = true
|
||||
upload_dir = "/www/tester/upload_here/"
|
||||
[[server.location]]
|
||||
location = "*.bla"
|
||||
cgi_pass = "~/.local/bin/cgi-test"
|
||||
[[server.location]]
|
||||
location = "/post_body"
|
||||
root = "www/tester/"
|
||||
methods = ["POST"]
|
||||
body_size_limit = 100
|
||||
[[server.location]]
|
||||
location = "/directory/"
|
||||
methods = ["GET"]
|
||||
root = "www/tester/YoupiBanane/"
|
||||
directory_file = "youpi.bad_extension"
|
||||
@@ -185,18 +185,27 @@ void Request::splitData(std::string &data)
|
||||
if (!_head_ok)
|
||||
{
|
||||
pos = str.find("\r\n\r\n");
|
||||
/* if (pos == -1) */
|
||||
/* { */
|
||||
/* _ret = 400; */
|
||||
/* return; */
|
||||
/* } */
|
||||
DBOUT << RED << "pos is " << pos << ENDL;
|
||||
if (pos == -1)
|
||||
{
|
||||
_ret = 400;
|
||||
return;
|
||||
_head += str;
|
||||
}
|
||||
else
|
||||
{
|
||||
_head += str.substr(0, pos) + "\n";
|
||||
_headerSize = _head.size() + 3;
|
||||
data.erase(0, pos + 4);
|
||||
_head_ok = true;
|
||||
|
||||
parseHeader();
|
||||
if (_contentLength == 0 && !_chunked)
|
||||
_body_ok = true;
|
||||
}
|
||||
_head = str.substr(0, pos) + "\n";
|
||||
_headerSize = _head.size() + 3;
|
||||
data.erase(0, pos + 4);
|
||||
_head_ok = true;
|
||||
parseHeader();
|
||||
if (_contentLength == 0 && !_chunked)
|
||||
_body_ok = true;
|
||||
}
|
||||
if (badCode(_ret))
|
||||
return ;
|
||||
@@ -336,6 +345,8 @@ bool Request::badCode(int code)
|
||||
|
||||
bool Request::ok(void)
|
||||
{
|
||||
DBOUT << "_head_ok " << _head_ok << ENDL;
|
||||
DBOUT << "_body_ok " << _body_ok << ENDL;
|
||||
return (_head_ok && _body_ok);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,18 +96,25 @@ void Server::readSocket(Client &client, int fd)
|
||||
bytes_read = recv(fd, &stringBUF[0], BUFFSIZE, 0);
|
||||
if (bytes_read == 0)
|
||||
{
|
||||
DBOUT << RED << "bytes_read = 0" << ENDL;
|
||||
client.allRead = true;
|
||||
throw std::logic_error("JOPA CLIENTU");
|
||||
return;
|
||||
}
|
||||
/* else if (bytes_read == -1) */
|
||||
/* throw std::logic_error("JOPA CLIENTU"); */
|
||||
// buf[bytes_read + 1] = '\0';
|
||||
DBOUT << stringBUF << ENDL;
|
||||
stringBUF.erase(bytes_read, stringBUF.size());
|
||||
/* DBOUT << "after erase" <<ENDL; */
|
||||
/* DBOUT << stringBUF << ENDL; */
|
||||
client.setRawData(stringBUF);
|
||||
// client.setRawData(buf);
|
||||
client.increaseRecvCounter(bytes_read);
|
||||
status = client.parseRequest();
|
||||
// client_map[fd].printClientInfo();
|
||||
|
||||
if ((bytes_read < BUFFSIZE) && client.allRecved())
|
||||
if (client.allRecved())
|
||||
{
|
||||
client.allRead = true;
|
||||
}
|
||||
@@ -153,7 +160,7 @@ void Server::add_to_epoll_list(int fd, unsigned int ep_events)
|
||||
ev.data.fd = fd;
|
||||
|
||||
assert(epoll_ctl(_epoll_fd, EPOLL_CTL_ADD, fd, &ev) == 0);
|
||||
/* setNonBlock(fd); */
|
||||
setNonBlock(fd);
|
||||
DBOUT << YELLO
|
||||
<< "add socket "
|
||||
<< fd
|
||||
@@ -263,13 +270,13 @@ void Server::start(void)
|
||||
assert( epoll_ctl(_epoll_fd, EPOLL_CTL_MOD, fd, &ev) == 0);
|
||||
DBOUT << GREEN << "rearmed to EPOLLOUT" << ENDL;
|
||||
}
|
||||
if (client_map[fd]->isEmpty())
|
||||
delete_client(client_map, fd);
|
||||
/* if (client_map[fd]->isEmpty()) */
|
||||
/* delete_client(client_map, fd); */
|
||||
}
|
||||
else if (events & EPOLLOUT)
|
||||
{
|
||||
/* DBOUT << GREEN << "doing sendData" << ENDL; */
|
||||
/* client_map[fd].printClientInfo(); */
|
||||
client_map[fd]->printClientInfo();
|
||||
sendData(*client_map[fd], fd);
|
||||
if (client_map[fd]->allSended())
|
||||
{
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace config
|
||||
|
||||
TOMLMap *parse(void)
|
||||
{
|
||||
std::string filename = "config/real.toml";
|
||||
std::string filename = "config/tester.toml";
|
||||
config::TOMLParser parser(filename);
|
||||
TOMLMap *root = parser.parse();
|
||||
/* config::display(root); */
|
||||
|
||||
BIN
ubuntu_tester
Executable file
BIN
ubuntu_tester
Executable file
Binary file not shown.
0
www/tester/YoupiBanane/Yeah/not_happy.bad_extension
Normal file
0
www/tester/YoupiBanane/Yeah/not_happy.bad_extension
Normal file
0
www/tester/YoupiBanane/nop/other.pouic
Normal file
0
www/tester/YoupiBanane/nop/other.pouic
Normal file
0
www/tester/YoupiBanane/nop/youpi.bad_extension
Normal file
0
www/tester/YoupiBanane/nop/youpi.bad_extension
Normal file
0
www/tester/YoupiBanane/youpi.bad_extension
Normal file
0
www/tester/YoupiBanane/youpi.bad_extension
Normal file
0
www/tester/YoupiBanane/youpi.bla
Normal file
0
www/tester/YoupiBanane/youpi.bla
Normal file
Reference in New Issue
Block a user