summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/cgi/cgiAppEngine.cpp1
-rw-r--r--project2/ice/iceDataSource.h1
-rw-r--r--project2/streams/streamPresenter.cpp72
3 files changed, 74 insertions, 0 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index 872f896..234cbeb 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -125,6 +125,7 @@ finalTransformSource(TransformSourcePtr ts)
void
CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const
{
+ IO.exceptions(std::ifstream::failbit | std::ifstream::badbit);
bool sessionEmpty = crc->getSession()->Empty();
crc->startTime = boost::date_time::microsec_clock<boost::posix_time::ptime>::universal_time();
bool triedNotFound = false;
diff --git a/project2/ice/iceDataSource.h b/project2/ice/iceDataSource.h
index b145fe5..47af13b 100644
--- a/project2/ice/iceDataSource.h
+++ b/project2/ice/iceDataSource.h
@@ -31,6 +31,7 @@ class IceDataSource : public DataSource {
return Interface::checkedCast(existingProxy->second);
}
+ const Ice::CommunicatorPtr GetCommunicator() const { return ic; }
static void FinaliseLoad();
private:
diff --git a/project2/streams/streamPresenter.cpp b/project2/streams/streamPresenter.cpp
new file mode 100644
index 0000000..3dde21c
--- /dev/null
+++ b/project2/streams/streamPresenter.cpp
@@ -0,0 +1,72 @@
+#include <pch.hpp>
+#include <presenter.h>
+#include <transform.h>
+#include <stream.h>
+
+class StreamPresenter : public Presenter, public WritableContent, public SourceOf<WritableContent> {
+ public:
+ StreamPresenter(ScriptNodePtr e, ObjectSource os, ExecContext * ) :
+ Presenter(os),
+ contentType(e, "contenttype", "application/octet-stream")
+ {
+ e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&stream));
+ }
+
+ WritableContent::Class getContentClass() const
+ {
+ return ClassData;
+ }
+
+ Glib::ustring getContentType() const
+ {
+ return contentType(NULL);
+ }
+
+ static size_t write(std::ostream * os, const char * data, size_t len)
+ {
+ os->write(data, len);
+ return len;
+ }
+
+ void writeTo(std::ostream & os, const std::string&, ExecContext * ec) const
+ {
+ if (stream) {
+ stream->runStream(boost::bind(&StreamPresenter::write, &os, _1, _2), ec);
+ }
+ }
+
+ void addNewArray(const Glib::ustring&, bool) const
+ {
+ }
+
+ void finishArray(bool) const
+ {
+ }
+
+ void init(ExecContext*)
+ {
+ }
+
+ void pushSub(const Glib::ustring&, const Glib::ustring&) const
+ {
+ }
+
+ void addText(const VariableType&) const
+ {
+ }
+
+ void popSub() const
+ {
+ }
+
+ operator const WritableContent * () const
+ {
+ return this;
+ }
+
+ private:
+ Variable contentType;
+ StreamPtr stream;
+};
+
+DECLARE_GENERIC_LOADER("stream", PresenterLoader, StreamPresenter)