46 #include "BESStreamResponseHandler.h"
47 #include "BESRequestHandlerList.h"
48 #include "BESForbiddenError.h"
49 #include "BESNotFoundError.h"
50 #include "BESInternalError.h"
51 #include "BESDataNames.h"
52 #include "BESContainer.h"
53 #include "BESDataHandlerInterface.h"
55 #define BES_STREAM_BUFFER_SIZE 4096
57 BESStreamResponseHandler::BESStreamResponseHandler(
const string &name) :
62 BESStreamResponseHandler::~BESStreamResponseHandler()
66 extern volatile int bes_timeout;
80 d_response_object = 0;
89 if (bes_timeout != 0) {
104 if (dhi.containers.size() != 1) {
105 string err = (string)
"Unable to stream file: " +
"no container specified";
111 string filename = container->
access();
112 if (filename.empty()) {
113 string err = (string)
"Unable to stream file: " +
"filename not specified";
119 os.open(filename.c_str(), ios::in);
122 string serr = (string)
"Unable to stream file because it cannot be opened. file: '" + filename +
"' msg: ";
123 char *err = strerror(myerrno);
127 serr +=
"Unknown error";
132 if (myerrno == ENOENT || myerrno == ENOTDIR) {
141 char block[BES_STREAM_BUFFER_SIZE];
142 os.read(block,
sizeof block);
143 nbytes = os.gcount();
146 dhi.get_output_stream().write((
char*) block, nbytes);
148 os.read(block,
sizeof block);
149 nbytes = os.gcount();
176 strm << BESIndent::LMarg <<
"BESStreamResponseHandler::dump - (" << (
void *)
this <<
")" << endl;
179 BESIndent::UnIndent();
183 BESStreamResponseHandler::BESStreamResponseBuilder(
const string &name)