Skip to content

Commit

Permalink
Merge branch 'master' into fix_macos
Browse files Browse the repository at this point in the history
  • Loading branch information
luca-schlecker authored Oct 14, 2021
2 parents efd5559 + 8f24107 commit 7f7eac9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 16 additions & 0 deletions include/crow/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ namespace crow
return *this;
}

/// Set a response body size (in bytes) beyond which Crow automatically streams responses (Default is 1MiB)

///
/// Any streamed response is unaffected by Crow's timer, and therefore won't timeout before a response is fully sent.
self_t& stream_threshold(size_t threshold)
{
res_stream_threshold_ = threshold;
return *this;
}

size_t& stream_threshold()
{
return res_stream_threshold_;
}

self_t& register_blueprint(Blueprint& blueprint)
{
router_.register_blueprint(blueprint);
Expand Down Expand Up @@ -400,6 +415,7 @@ namespace crow
bool validated_ = false;
std::string server_name_ = std::string("Crow/") + VERSION;
std::string bindaddr_ = "0.0.0.0";
size_t res_stream_threshold_ = 1048576;
Router router_;

#ifdef CROW_ENABLE_COMPRESSION
Expand Down
7 changes: 4 additions & 3 deletions include/crow/http_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ namespace crow
server_name_(server_name),
middlewares_(middlewares),
get_cached_date_str(get_cached_date_str_f),
timer_queue(timer_queue)
timer_queue(timer_queue),
res_stream_threshold_(handler->stream_threshold())
{
#ifdef CROW_ENABLE_DEBUG
connectionCount ++;
Expand Down Expand Up @@ -678,8 +679,6 @@ namespace crow

boost::array<char, 4096> buffer_;

const unsigned res_stream_threshold_ = 1048576;

HTTPParser<Connection> parser_;
request req_;
response res;
Expand Down Expand Up @@ -707,6 +706,8 @@ namespace crow

std::function<std::string()>& get_cached_date_str;
detail::dumb_timer_queue& timer_queue;

size_t res_stream_threshold_;
};

}

0 comments on commit 7f7eac9

Please sign in to comment.