diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/src/http-server/http-server.cc | 32 | ||||
-rw-r--r-- | apps/src/http-server/http-server/http_server.cc | 4 |
2 files changed, 32 insertions, 4 deletions
diff --git a/apps/src/http-server/http-server.cc b/apps/src/http-server/http-server.cc index 7f6f8a3e8..0a224088d 100644 --- a/apps/src/http-server/http-server.cc +++ b/apps/src/http-server/http-server.cc @@ -56,6 +56,35 @@ string getFileName(const string &strPath) { #endif } +int _mkdir(const char *dir) { + std::cout << dir << std::endl; + char tmp[PATH_MAX]; + char *p = NULL; + size_t len; + + snprintf(tmp, sizeof(tmp), "%s", dir); + len = strlen(tmp); + if (tmp[len - 1] == '/') + tmp[len - 1] = 0; + for (p = tmp + 1; *p; p++) { + if (*p == '/') { + *p = 0; + if (!(std::ifstream(tmp).good())) { + if (mkdir(tmp, S_IRWXU) == -1) + return -1; + } + *p = '/'; + } + } + + if (!(std::ifstream(tmp).good())) { + if (mkdir(tmp, S_IRWXU) == -1) + return -1; + } + + return 0; +} + string getExtension(const string &strPath) { size_t iLastSeparator = 0; return strPath.substr((iLastSeparator = strPath.find_last_of(".")) != @@ -157,8 +186,7 @@ int main(int argc, char **argv) { } } if (!(std::ifstream(root_folder).good())) { - if (mkdir(root_folder.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == - -1) { + if (_mkdir(root_folder.c_str()) == -1) { std::cerr << "The web root folder " << root_folder << " does not exist and its creation failed. Exiting.." << std::endl; diff --git a/apps/src/http-server/http-server/http_server.cc b/apps/src/http-server/http-server/http_server.cc index 911656f7a..8c8bea60a 100644 --- a/apps/src/http-server/http-server/http_server.cc +++ b/apps/src/http-server/http-server/http_server.cc @@ -226,8 +226,8 @@ void HttpServer::read_request_and_content(std::shared_ptr<socket_type> socket) { if (!ec) { // request->streambuf.size() is not necessarily the same as // bytes_transferred, from Asio-docs: "After a successful - //async_read_until operation, the streambuf may contain additional - //data beyond the delimiter" The chosen solution is to extract lines + // async_read_until operation, the streambuf may contain additional + // data beyond the delimiter" The chosen solution is to extract lines // from the stream directly when parsing the header. What is left of // the streambuf (maybe some bytes of the content) is appended to in // the async_read-function below (for retrieving content). |