44 #include "BESStreamResponseHandler.h" 45 #include "BESRequestHandlerList.h" 46 #include "BESNotFoundError.h" 47 #include "BESInternalError.h" 48 #include "BESDataNames.h" 49 #include "BESContainer.h" 51 #define BES_STREAM_BUFFER_SIZE 4096 53 BESStreamResponseHandler::BESStreamResponseHandler(
const string &name )
58 BESStreamResponseHandler::~BESStreamResponseHandler( )
87 if( dhi.containers.size() != 1 )
89 string err = (string)
"Unable to stream file: " 90 +
"no container specified" ;
96 string filename = container->
access() ;
97 if( filename.empty() )
99 string err = (string)
"Unable to stream file: " 100 +
"filename not specified" ;
106 os.open( filename.c_str(), ios::in ) ;
107 int myerrno = errno ;
110 string serr = (string)
"Unable to stream file: " 111 +
"cannot open file " 113 char *err = strerror( myerrno ) ;
117 serr +=
"Unknown error" ;
123 char block[BES_STREAM_BUFFER_SIZE] ;
124 os.read( block,
sizeof block ) ;
125 nbytes = os.gcount() ;
129 dhi.get_output_stream().write( (
char*)block, nbytes ) ;
130 os.read( block,
sizeof block ) ;
131 nbytes = os.gcount() ;
160 strm << BESIndent::LMarg <<
"BESStreamResponseHandler::dump - (" 161 << (
void *)
this <<
")" << endl ;
162 BESIndent::Indent() ;
164 BESIndent::UnIndent() ;
168 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
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
virtual void dump(ostream &strm) const
dumps information about this object
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