Skip to content

Commit

Permalink
Add timeout and rate limit for http server
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Sep 4, 2024
1 parent fd42ca7 commit 8793e16
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions proxy/include/proxy/proxy_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4235,6 +4235,8 @@ R"x*x*x(<html>
char* buf = bufs.get();
std::streamsize total = 0;

stream_rate_limit(m_local_socket, m_option.tcp_rate_limit_);

do
{
auto bytes_transferred = fileop::read(file, std::span<char>(buf, buf_size));
Expand All @@ -4255,6 +4257,8 @@ R"x*x*x(<html>
res.body().more = true;
}

stream_expires_after(m_local_socket, std::chrono::seconds(m_option.tcp_timeout_));

co_await http::async_write(
m_local_socket,
sr,
Expand Down

0 comments on commit 8793e16

Please sign in to comment.