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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user