From 40735bb1229ae0369e7d763964ffbe543334b7c9 Mon Sep 17 00:00:00 2001 From: Roland Reichwein Date: Sun, 19 Apr 2020 15:59:07 +0200 Subject: Fix CGI i/o --- plugins/cgi/cgi.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'plugins/cgi') diff --git a/plugins/cgi/cgi.cpp b/plugins/cgi/cgi.cpp index f5147c1..b8c2470 100644 --- a/plugins/cgi/cgi.cpp +++ b/plugins/cgi/cgi.cpp @@ -100,6 +100,8 @@ namespace { { "CONTENT-TYPE", [](std::string& v, CGIContext& c){ c.SetResponseHeader("content_type", v); } }, + { "SET-COOKIE", [](std::string& v, CGIContext& c){ c.SetResponseHeader("set_cookie", v); } }, + { "STATUS", [](std::string& v, CGIContext& c) { std::string status{"500"}; if (v.size() >= 3) { @@ -170,18 +172,17 @@ namespace { std::string executeFile(const fs::path& filename, CGIContext& context) { - bp::opstream is_in; + bp::pipe is_in; bp::ipstream is_out; - //std::cout << "Executing " << filename << std::endl; - bp::environment env {boost::this_process::environment()}; setCGIEnvironment(env, context); - bp::child child(filename.string(), env, (bp::std_out & bp::std_err) > is_out, bp::std_in < is_in); + bp::child child(filename.string(), env, bp::std_out > is_out, bp::std_err > stderr, bp::std_in < is_in); - is_in << context.GetRequestParam("body"); - //is_in.close(); + std::string body{ context.GetRequestParam("body") }; + is_in.write(body.data(), body.size()); + is_in.close(); std::string output; std::string line; -- cgit v1.2.3