Wip chunked decoding

+ Need to test normal body parsing
+ path_is_valid() renamed eval_file_type()
+ replaced atoi with strtol/strtoul
This commit is contained in:
LuckyLaszlo
2022-08-12 05:50:00 +02:00
parent ab0bc2c4c0
commit 400efbe720
18 changed files with 185 additions and 82 deletions

View File

@@ -65,7 +65,7 @@ bool isNumeric_btw(int low, int high, std::string str)
if (std::isdigit(str[i]) == false)
return false;
}
int n = std::atoi(str.c_str());
int n = std::strtol(str.c_str(), NULL, 10);
if (n < low || n > high)
return false;
return true;
@@ -106,26 +106,23 @@ std::string http_methods_to_str(unsigned int methods)
# include <iostream>
// you could make this &path...
int path_is_valid(std::string path)
file_type eval_file_type(const std::string &path)
{
const char *tmp_path = path.c_str();
struct stat s;
if (stat(tmp_path, &s) == 0)
if (stat(tmp_path, &s) != -1)
{
if (S_ISREG(s.st_mode))
{
// std::cout << "is a file\n";
return (IS_FILE);
}
else if (S_ISDIR(s.st_mode))
{
// std::cout << "is a Dir\n";
return (IS_DIR);
}
}
// std::cout << "path is neither dir nor file\n";
else
{
std::perror("err stat()");
}
return (IS_OTHER);
}