diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-21 21:58:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-01-21 21:58:57 +0000 |
commit | ba85a0bc4ec54a124264327800c173e4dd5fc83a (patch) | |
tree | 75b3dd48b7b3b59505cbe37a5742d99d045ce77d | |
parent | Add workaround for has_result_type not correctly handling references (diff) | |
download | project2-1.2.4.tar.bz2 project2-1.2.4.tar.xz project2-1.2.4.zip |
Ignore IO errors writing CgiResults to clients as they may be gone awayproject2-1.2.4
-rw-r--r-- | project2/cgi/cgiResultStatic.cpp | 9 | ||||
-rw-r--r-- | project2/cgi/cgiResultWritable.cpp | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/project2/cgi/cgiResultStatic.cpp b/project2/cgi/cgiResultStatic.cpp index ab4ff43..8abeb05 100644 --- a/project2/cgi/cgiResultStatic.cpp +++ b/project2/cgi/cgiResultStatic.cpp @@ -15,8 +15,13 @@ class StaticToCgiResult : public TransformImpl<StaticContent, CgiResult> { cr->header->addHeader("Last-Modified", buf); cr->header->addHeader("Etag", sc->getSHA1()); cr->header->addHeader("Cache-Control", "must-revalidate"); - cr->header->render(cr->stream); - sc->writeTo(cr->stream); + try { + cr->header->render(cr->stream); + sc->writeTo(cr->stream); + } + catch (const std::ios_base::failure &) { + // ignore (client may have gone away) + } } }; DECLARE_TRANSFORM(StaticToCgiResult); diff --git a/project2/cgi/cgiResultWritable.cpp b/project2/cgi/cgiResultWritable.cpp index 1364456..45e2a2a 100644 --- a/project2/cgi/cgiResultWritable.cpp +++ b/project2/cgi/cgiResultWritable.cpp @@ -30,8 +30,13 @@ class WritableToCgiResult : public TransformImpl<WritableContent, CgiResult> { strftime(buf, sizeof(buf), "%a, %d %b %Y %T %z", &stm); cr->header->addHeader("Last-Modified", buf); } - cr->header->render(cr->stream); - wc->writeTo(cr->stream, cr->encoding, ec); + try { + cr->header->render(cr->stream); + wc->writeTo(cr->stream, cr->encoding, ec); + } + catch (const std::ios_base::failure &) { + // ignore (client may have gone away) + } } }; DECLARE_TRANSFORM(WritableToCgiResult); |