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)
error thrown if the resource requested cannot be found
exception thrown if inernal error encountered
virtual void execute(BESDataHandlerInterface &r)
executes the command 'get file <filename>;' by streaming the specified file
virtual string access()=0
returns the true name of this container
virtual void dump(ostream &strm) const
dumps information about this object
handler object that knows how to create a specific response object
virtual void transmit(BESTransmitter *transmitter, BESDataHandlerInterface &r)
transmit the file, streaming it back to the client
error thrown if the BES is not allowed to access the resource requested
Structure storing information used by the BES to handle the request.
void first_container()
set the container pointer to the first container in the containers list
A container is something that holds data. E.G., a netcdf file or a database entry.
virtual void dump(std::ostream &strm) const
dumps information about this object
BESContainer * container
pointer to current container in this interface