46 #include "BESStreamResponseHandler.h" 47 #include "BESRequestHandlerList.h" 48 #include "BESNotFoundError.h" 49 #include "BESInternalError.h" 50 #include "BESDataNames.h" 51 #include "BESContainer.h" 53 #define BES_STREAM_BUFFER_SIZE 4096 55 BESStreamResponseHandler::BESStreamResponseHandler(
const string &name) :
60 BESStreamResponseHandler::~BESStreamResponseHandler()
64 extern volatile int bes_timeout;
87 if (bes_timeout != 0) {
102 if (dhi.containers.size() != 1) {
103 string err = (string)
"Unable to stream file: " +
"no container specified";
109 string filename = container->
access();
110 if (filename.empty()) {
111 string err = (string)
"Unable to stream file: " +
"filename not specified";
117 os.open(filename.c_str(), ios::in);
120 string serr = (string)
"Unable to stream file: " +
"cannot open file " + filename +
": ";
121 char *err = strerror(myerrno);
125 serr +=
"Unknown error";
131 char block[BES_STREAM_BUFFER_SIZE];
132 os.read(block,
sizeof block);
133 nbytes = os.gcount();
136 dhi.get_output_stream().write((
char*) block, nbytes);
138 os.read(block,
sizeof block);
139 nbytes = os.gcount();
166 strm << BESIndent::LMarg <<
"BESStreamResponseHandler::dump - (" << (
void *)
this <<
")" << endl;
169 BESIndent::UnIndent();
173 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
Structure storing information used by the BES to handle the request.
virtual void dump(ostream &strm) const
dumps information about this object
void first_container()
set the container pointer to the first container in the containers list
A container is something that holds data. I.E. a netcdf file or a database entry. ...
BESContainer * container
pointer to current container in this interface