summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--debian/changelog1
-rw-r--r--plugins/fcgi/socket.cpp2
-rw-r--r--tests/test-webserver.cpp47
3 files changed, 48 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index b16b192..0ebbed9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,7 @@ webserver (1.18~pre1) UNRELEASED; urgency=medium
* Added websockets support (configurable forwarding proxy)
* CGI bugfix: Executable execute bits check
* Added example configurations
+ * FCGI bugfix: IPv6 support
-- Roland Reichwein <mail@reichwein.it> Sun, 08 Jan 2023 15:26:48 +0100
diff --git a/plugins/fcgi/socket.cpp b/plugins/fcgi/socket.cpp
index 82bb06b..2b34bc3 100644
--- a/plugins/fcgi/socket.cpp
+++ b/plugins/fcgi/socket.cpp
@@ -22,7 +22,7 @@ SocketFactory::SocketFactory()
std::shared_ptr<Socket> SocketFactory::create(const std::string& app_addr)
{
- size_t pos { app_addr.find(':') };
+ size_t pos { app_addr.find_last_of(':') };
if (pos != app_addr.npos) { // tcp socket: host:port
return std::make_shared<TCPSocket>(app_addr.substr(0, pos), app_addr.substr(pos + 1), m_io_context);
diff --git a/tests/test-webserver.cpp b/tests/test-webserver.cpp
index 714cdf2..bd89aab 100644
--- a/tests/test-webserver.cpp
+++ b/tests/test-webserver.cpp
@@ -604,7 +604,7 @@ BOOST_FIXTURE_TEST_CASE(http_redirect, Fixture)
BOOST_CHECK_EQUAL(result.second, "301 Redirecting to reichwein.it ...");
}
-BOOST_FIXTURE_TEST_CASE(http_fcgi, Fixture)
+BOOST_FIXTURE_TEST_CASE(http_fcgi_ip4, Fixture)
{
std::string webserver_config{R"CONFIG(<webserver>
<user>www-data</user>
@@ -649,3 +649,48 @@ BOOST_FIXTURE_TEST_CASE(http_fcgi, Fixture)
BOOST_CHECK_EQUAL(result.second, "returning data of : ");
}
+BOOST_FIXTURE_TEST_CASE(http_fcgi_ip6, Fixture)
+{
+ std::string webserver_config{R"CONFIG(<webserver>
+ <user>www-data</user>
+ <group>www-data</group>
+ <threads>10</threads>
+ <statisticspath>stats.db</statisticspath>
+ <plugin-directory>../plugins</plugin-directory>
+ <sites>
+ <site>
+ <name>localhost</name>
+ <host>localhost</host>
+ <host>[::1]</host>
+ <path requested="/fcgi">
+ <plugin>fcgi</plugin>
+ <target>::1:8765</target>
+ </path>
+ </site>
+ </sites>
+ <sockets>
+ <socket>
+ <address>::1</address>
+ <port>8080</port>
+ <protocol>http</protocol>
+ <site>localhost</site>
+ </socket>
+ </sockets>
+</webserver>)CONFIG"};
+ WebserverProcess serverProcess{webserver_config};
+ BOOST_REQUIRE(serverProcess.is_running());
+
+ FastCGIProcess fcgiProcess("./fcgi1", "::1", 8765);
+ BOOST_REQUIRE(fcgiProcess.is_running());
+
+ auto result {HTTP("/fcgi/abc")};
+ BOOST_CHECK_EQUAL(result.first, fmt::format(
+"HTTP/1.1 200 OK\r\n"
+"Server: Reichwein.IT Webserver {}\r\n"
+"Content-Type: text/plain\r\n"
+"Content-Length: {}\r\n"
+"\r\n"
+ , VERSION, result.second.size()));
+ BOOST_CHECK_EQUAL(result.second, "returning data of : ");
+}
+