47 #include "BESStreamResponseHandler.h"
48 #include "BESRequestHandlerList.h"
49 #include "BESForbiddenError.h"
50 #include "BESNotFoundError.h"
51 #include "BESInternalError.h"
52 #include "BESDataNames.h"
53 #include "BESContainer.h"
54 #include "BESDataHandlerInterface.h"
56 #define BES_STREAM_BUFFER_SIZE 4096
58 BESStreamResponseHandler::BESStreamResponseHandler(
const string &name) :
63 BESStreamResponseHandler::~BESStreamResponseHandler()
67 extern volatile int bes_timeout;
81 d_response_object = 0;
90 if (bes_timeout != 0) {
105 if (dhi.containers.size() != 1) {
106 string err = (string)
"Unable to stream file: " +
"no container specified";
112 string filename = container->
access();
113 if (filename.empty()) {
114 string err = (string)
"Unable to stream file: " +
"filename not specified";
120 os.open(filename.c_str(), ios::in);
123 string serr = (string)
"Unable to stream file because it cannot be opened. file: '" + filename +
"' msg: ";
124 char *err = strerror(myerrno);
128 serr +=
"Unknown error";
133 if (myerrno == ENOENT || myerrno == ENOTDIR) {
142 char block[BES_STREAM_BUFFER_SIZE];
143 os.read(block,
sizeof block);
144 nbytes = os.gcount();
147 dhi.get_output_stream().write((
char*) block, nbytes);
149 os.read(block,
sizeof block);
150 nbytes = os.gcount();
177 strm << BESIndent::LMarg <<
"BESStreamResponseHandler::dump - (" << (
void *)
this <<
")" << endl;
180 BESIndent::UnIndent();
184 BESStreamResponseHandler::BESStreamResponseBuilder(
const string &name)