summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-05-30 22:40:52 +0200
committerRoland Reichwein <mail@reichwein.it>2020-05-30 22:40:52 +0200
commitb715de1eb6f937b0a05d91842041a54455946061 (patch)
tree8ff497cf574be954bacc3c8844446cbc740ead43
parented3fcf6ef315fc6fe1519f0c67377267bd95666d (diff)
Bugfixes: write timeout and output size
-rw-r--r--debian/changelog7
-rw-r--r--http.cpp1
-rw-r--r--https.cpp3
-rw-r--r--plugins/fcgi/fcgi.cpp17
-rw-r--r--webserver.conf9
5 files changed, 24 insertions, 13 deletions
diff --git a/debian/changelog b/debian/changelog
index eb9a600..1a7b163 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+webserver (1.9) UNRELEASED; urgency=medium
+
+ * Fix fcgi output size (content-length was 1 too big)
+ * Fix timeout for writing (output)
+
+ -- Roland Reichwein <rr@antcom.de> Sat, 30 May 2020 22:39:49 +0200
+
webserver (1.8) unstable; urgency=medium
* Automatically reopen broken fcgi sockets
diff --git a/http.cpp b/http.cpp
index 6a488ed..1d3edee 100644
--- a/http.cpp
+++ b/http.cpp
@@ -63,6 +63,7 @@ class session : public std::enable_shared_from_this<session>
void handle_request(::Server& server, request_type&& req)
{
+ stream_.expires_after(std::chrono::seconds(300)); // timeout on write by server much longer than read timeout from client
auto sp = std::make_shared<response_type>(generate_response(req, server));
res_ = sp;
diff --git a/https.cpp b/https.cpp
index e56af9a..50ea31c 100644
--- a/https.cpp
+++ b/https.cpp
@@ -98,6 +98,7 @@ class session : public std::enable_shared_from_this<session>
void handle_request(::Server& server, request_type&& req)
{
+ beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(300)); // timeout on write by server much longer than read timeout from client
auto sp = std::make_shared<response_type>(generate_response(req, server));
res_ = sp;
@@ -225,7 +226,7 @@ public:
&session::on_read,
shared_from_this()));
#else
- http::async_read(stream_, buffer_, *parser_,
+ http::async_read(stream_, buffer_, *parser_,
boost::asio::bind_executor(
strand_,
std::bind(
diff --git a/plugins/fcgi/fcgi.cpp b/plugins/fcgi/fcgi.cpp
index 22a4d40..0d845a6 100644
--- a/plugins/fcgi/fcgi.cpp
+++ b/plugins/fcgi/fcgi.cpp
@@ -453,7 +453,6 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context)
}
std::istringstream is_out{output_data};
- std::string output;
std::string line;
// TODO: C++20 coroutine
@@ -469,25 +468,19 @@ std::string fcgi_plugin::fcgiQuery(FCGIContext& context)
// read empty line
if (!isEmpty(line))
throw std::runtime_error("Missing empty line between CGI header and body");
- if (in)
- in();
- // read remainder
- while (in) {
- line = in.get();
- output += line + '\n';
+ if (in)
in();
- }
-
- throw std::runtime_error("Input missing on processing CGI body");
});
do {
std::getline(is_out, line);
processLine(line);
- } while (!is_out.eof());
+ } while (!is_out.eof() && !isEmpty(line));
+
+ std::string r = output_data.substr(is_out.tellg());
- return output;
+ return r;
}
std::string fcgi_plugin::name()
diff --git a/webserver.conf b/webserver.conf
index 871a491..3a4d6f7 100644
--- a/webserver.conf
+++ b/webserver.conf
@@ -82,6 +82,15 @@
<target>/home/ernie/code/webshop/html</target>
</path>
+ <path requested="/downtube">
+ <plugin>static-files</plugin>
+ <target>/home/ernie/homepage/reichwein.it/downtube</target>
+ </path>
+ <path requested="/downtube/downtube.fcgi">
+ <plugin>fcgi</plugin>
+ <target>127.0.0.1:9004</target>
+ </path>
+
<path requested="/redirect1">
<plugin>redirect</plugin>
<target>https://www.antcom.de/</target>