summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/cgi/cgiResultStatic.cpp9
-rw-r--r--project2/cgi/cgiResultWritable.cpp9
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);