Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Nov 20, 2024
1 parent 3b453ac commit 3caf858
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions include/cinatra/coro_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ class coro_http_server {

if (!file_path.empty()) {
static_dir_ = std::filesystem::path(file_path).make_preferred().string();
if (auto pos = static_dir_.find("./"); pos != std::string::npos) {
static_dir_ = static_dir_.substr(static_dir_.find("./") + 2);
if (static_dir_.empty()) {
static_dir_ = fs::absolute(fs::current_path().string()).string();
}
}
}
else {
static_dir_ = fs::absolute(fs::current_path().string()).string();
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cinatra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ TEST_CASE("test multiple ranges download") {
TEST_CASE("test ranges download") {
create_file("test_range.txt", 64);
coro_http_server server(1, 8090);
server.set_static_res_dir("", "");
server.set_static_res_dir("", "./");
server.async_start();

coro_http_client client{};
Expand Down
2 changes: 1 addition & 1 deletion tests/test_coro_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ TEST_CASE("test reverse proxy") {

coro_http_server proxy_wrr(2, 8090);
proxy_wrr.set_http_proxy_handler<GET, POST>(
"/", {"127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"},
"/", {"http://127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"},
coro_io::load_blance_algorithm::WRR, {10, 5, 5}, log_t{}, check_t{});

coro_http_server proxy_rr(2, 8091);
Expand Down

0 comments on commit 3caf858

Please sign in to comment.