summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--debian/changelog1
-rw-r--r--debian/control1
-rw-r--r--http.cpp9
-rw-r--r--https.cpp9
5 files changed, 16 insertions, 5 deletions
diff --git a/TODO b/TODO
index d5dbf8b..5bd65c5 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-Upload: read: body limit exceeded
weblog: blättern
weblog: link consistency check (cron?)
weblog: style: zitate
diff --git a/debian/changelog b/debian/changelog
index 5b7f88a..d6456d3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ webserver (1.3) unstable; urgency=medium
* Updated weblog
* Added statistics
+ * Removed upload limit (now 1GB)
-- Roland Reichwein <rr@antcom.de> Sat, 25 Apr 2020 12:35:44 +0200
diff --git a/debian/control b/debian/control
index a362f10..5b4833a 100644
--- a/debian/control
+++ b/debian/control
@@ -20,3 +20,4 @@ Description: Web server
- HTTP and HTTPs via OpenSSL
- Virtual Servers
- CGI interface
+ - Upload/Download Statistics
diff --git a/http.cpp b/http.cpp
index a4709bb..ce3309f 100644
--- a/http.cpp
+++ b/http.cpp
@@ -56,6 +56,7 @@ class session : public std::enable_shared_from_this<session>
#endif
beast::flat_buffer buffer_;
Server& m_server;
+ http::request_parser<http::string_body> parser_;
request_type req_;
std::shared_ptr<response_type> res_;
@@ -106,6 +107,7 @@ public:
#endif
, m_server(server)
{
+ parser_.body_limit(1000000000); // 1GB limit
}
// Start the asynchronous operation
@@ -136,13 +138,13 @@ public:
stream_.expires_after(std::chrono::seconds(30));
// Read a request
- http::async_read(stream_, buffer_, req_,
+ http::async_read(stream_, buffer_, parser_,
beast::bind_front_handler(
&session::on_read,
shared_from_this()));
#else
- http::async_read(socket_, buffer_, req_,
+ http::async_read(socket_, buffer_, parser_,
boost::asio::bind_executor(
strand_,
std::bind(
@@ -173,6 +175,9 @@ public:
if(ec)
return fail(ec, "read");
+ req_ = parser_.get();
+ parser_.release();
+
// Send the response
handle_request(m_server, std::move(req_));
}
diff --git a/https.cpp b/https.cpp
index 7c94099..f02a1b7 100644
--- a/https.cpp
+++ b/https.cpp
@@ -90,6 +90,7 @@ class session : public std::enable_shared_from_this<session>
#endif
beast::flat_buffer buffer_;
Server& m_server;
+ http::request_parser<http::string_body> parser_;
http::request<http::string_body> req_;
std::shared_ptr<response_type> res_;
@@ -142,6 +143,7 @@ public:
#endif
, m_server(server)
{
+ parser_.body_limit(1000000000); // 1GB limit
}
// Start the asynchronous operation
@@ -212,12 +214,12 @@ public:
beast::get_lowest_layer(stream_).expires_after(std::chrono::seconds(30));
// Read a request
- http::async_read(stream_, buffer_, req_,
+ http::async_read(stream_, buffer_, parser_,
beast::bind_front_handler(
&session::on_read,
shared_from_this()));
#else
- http::async_read(stream_, buffer_, req_,
+ http::async_read(stream_, buffer_, parser_,
boost::asio::bind_executor(
strand_,
std::bind(
@@ -246,6 +248,9 @@ public:
if(ec)
return fail(ec, "read");
+ req_ = parser_.get();
+ parser_.release();
+
// Send the response
handle_request(m_server, std::move(req_));
}