|
libdap++
Updated for version 3.8.2
|
Build responses for Hyrax server modules/handlers. More...
#include <ResponseBuilder.h>

Public Member Functions | |
| virtual void | dataset_constraint (ostream &out, DDS &dds, ConstraintEvaluator &eval, bool ce_eval=true) const |
| virtual void | dataset_constraint_ddx (ostream &out, DDS &dds, ConstraintEvaluator &eval, const string &boundary, const string &start, bool ce_eval=true) const |
| virtual void | establish_timeout (ostream &stream) const |
| virtual string | get_ce () const |
| Get the constraint expression. | |
| virtual string | get_dataset_name () const |
| Get the dataset name. | |
| int | get_timeout () const |
| ResponseBuilder () | |
| virtual void | send_das (ostream &out, DAS &das, bool with_mime_headers=true) const |
| Transmit a DAS. | |
| virtual void | send_data (ostream &data_stream, DDS &dds, ConstraintEvaluator &eval, bool with_mime_headers=true) const |
| Transmit data. | |
| virtual void | send_data_ddx (ostream &data_stream, DDS &dds, ConstraintEvaluator &eval, const string &start, const string &boundary, bool with_mime_headers=true) const |
| Transmit data. | |
| virtual void | send_dds (ostream &out, DDS &dds, ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true) const |
| Transmit a DDS. | |
| virtual void | send_ddx (ostream &out, DDS &dds, ConstraintEvaluator &eval, bool with_mime_headers=true) const |
| virtual void | set_ce (string _ce) |
| virtual void | set_dataset_name (const string _dataset) |
| void | set_mime_binary (ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const |
| void | set_mime_data_boundary (ostream &out, const string &boundary, const string &cid, ObjectType type=unknown_type, EncodingType enc=x_plain) const |
| void | set_mime_ddx_boundary (ostream &out, const string &boundary, const string &start, ObjectType type=unknown_type, EncodingType enc=x_plain) const |
| void | set_mime_error (ostream &out, int code=404, const string &reason="Dataset not found", const string &protocol="") const |
| void | set_mime_html (ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const |
| void | set_mime_multipart (ostream &out, const string &boundary, const string &start, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const |
| void | set_mime_text (ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const |
| void | set_timeout (int timeout=0) |
| virtual | ~ResponseBuilder () |
Protected Member Functions | |
| void | initialize () |
| Version string for the library's default protocol version. | |
Protected Attributes | |
| string | d_ce |
| Name of the dataset/database. | |
| string | d_dataset |
| string | d_default_protocol |
| Response timeout after N seconds. | |
| int | d_timeout |
| Constraint expression. | |
Friends | |
| class | ResponseBuilderTest |
Definition at line 60 of file ResponseBuilder.h.
| libdap::ResponseBuilder::ResponseBuilder | ( | ) | [inline] |
Make an empty instance. Use the set_*() methods to load with needed values. You must call at least set_dataset_name() or be requesting version information.
Definition at line 82 of file ResponseBuilder.h.
References initialize().

| libdap::ResponseBuilder::~ResponseBuilder | ( | ) | [virtual] |
Definition at line 67 of file ResponseBuilder.cc.
| void libdap::ResponseBuilder::dataset_constraint | ( | ostream & | out, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| bool | ce_eval = true |
||
| ) | const [virtual] |
Definition at line 307 of file ResponseBuilder.cc.
References DBG, libdap::DDS::print_constrained(), libdap::DDS::var_begin(), and libdap::DDS::var_end().

| void libdap::ResponseBuilder::dataset_constraint_ddx | ( | ostream & | out, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| const string & | boundary, | ||
| const string & | start, | ||
| bool | ce_eval = true |
||
| ) | const [virtual] |
Definition at line 330 of file ResponseBuilder.cc.
References libdap::binary, libdap::dap4_data, libdap::dap4_ddx, DBG, libdap::DDS::print_xml(), libdap::set_mime_data_boundary(), libdap::set_mime_ddx_boundary(), libdap::DDS::var_begin(), and libdap::DDS::var_end().

| void libdap::ResponseBuilder::establish_timeout | ( | ostream & | stream | ) | const [virtual] |
Use values of this instance to establish a timeout alarm for the server. If the timeout value is zero, do nothing.
Definition at line 238 of file ResponseBuilder.cc.
References libdap::SignalHandler::register_handler().

| string libdap::ResponseBuilder::get_ce | ( | ) | const [virtual] |
Return the entire constraint expression in a string. This includes both the projection and selection clauses, but not the question mark.
Definition at line 153 of file ResponseBuilder.cc.
| string libdap::ResponseBuilder::get_dataset_name | ( | ) | const [virtual] |
The ``dataset name'' is the filename or other string that the filter program will use to access the data. In some cases this will indicate a disk file containing the data. In others, it may represent a database query or some other exotic data access method.
Definition at line 203 of file ResponseBuilder.cc.
| int libdap::ResponseBuilder::get_timeout | ( | ) | const |
Get the server's timeout value.
Definition at line 223 of file ResponseBuilder.cc.
| void libdap::ResponseBuilder::initialize | ( | ) | [protected] |
Called when initializing a ResponseBuilder that's not going to be passed a command line arguments.
Definition at line 73 of file ResponseBuilder.cc.
References DAP_PROTOCOL_VERSION.
Referenced by ResponseBuilder().
| void libdap::ResponseBuilder::send_das | ( | ostream & | out, |
| DAS & | das, | ||
| bool | with_mime_headers = true |
||
| ) | const [virtual] |
This function formats and prints an ASCII representation of a DAS on stdout. This has the effect of sending the DAS object back to the client program.
| out | The output stream to which the DAS is to be sent. |
| das | The DAS object to be sent. |
| anc_location | The directory in which the external DAS file resides. |
| with_mime_headers | If true (the default) send MIME headers. |
Definition at line 261 of file ResponseBuilder.cc.
References libdap::dods_das, libdap::last_modified_time(), libdap::DAS::print(), libdap::set_mime_text(), and libdap::x_plain.

| void libdap::ResponseBuilder::send_data | ( | ostream & | data_stream, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| bool | with_mime_headers = true |
||
| ) | const [virtual] |
Send the data in the DDS object back to the client program. The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream. If this is being called from a CGI, data_stream is probably stdout and writing to it has the effect of sending the response back to the client.
| dds | A DDS object containing the data to be sent. |
| eval | A reference to the ConstraintEvaluator to use. |
| data_stream | Write the response to this stream. |
| anc_location | A directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time(). |
| with_mime_headers | If true, include the MIME headers in the response. Defaults to true. |
Definition at line 385 of file ResponseBuilder.cc.
References libdap::dods_data, libdap::ConstraintEvaluator::eval_function_clauses(), libdap::ConstraintEvaluator::function_clauses(), libdap::DDS::get_dap_version(), libdap::last_modified_time(), libdap::ConstraintEvaluator::parse_constraint(), libdap::set_mime_binary(), libdap::DDS::set_timeout(), libdap::DDS::tag_nested_sequences(), and libdap::x_plain.

| void libdap::ResponseBuilder::send_data_ddx | ( | ostream & | data_stream, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| const string & | start, | ||
| const string & | boundary, | ||
| bool | with_mime_headers = true |
||
| ) | const [virtual] |
Send the data in the DDS object back to the client program. The data is encoded using a Marshaller, and enclosed in a MIME document which is all sent to data_stream. If this is being called from a CGI, data_stream is probably stdout and writing to it has the effect of sending the response back to the client.
| dds | A DDS object containing the data to be sent. |
| eval | A reference to the ConstraintEvaluator to use. |
| data_stream | Write the response to this stream. |
| anc_location | A directory to search for ancillary files (in addition to the CWD). This is used in a call to get_data_last_modified_time(). |
| with_mime_headers | If true, include the MIME headers in the response. Defaults to true. |
Definition at line 458 of file ResponseBuilder.cc.
References CRLF, libdap::dap4_data_ddx, libdap::ConstraintEvaluator::eval_function_clauses(), libdap::ConstraintEvaluator::function_clauses(), libdap::last_modified_time(), libdap::ConstraintEvaluator::parse_constraint(), libdap::set_mime_multipart(), libdap::DDS::set_timeout(), libdap::DDS::tag_nested_sequences(), and libdap::x_plain.

| void libdap::ResponseBuilder::send_dds | ( | ostream & | out, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| bool | constrained = false, |
||
| bool | with_mime_headers = true |
||
| ) | const [virtual] |
This function formats and prints an ASCII representation of a DDS on stdout. When called by a CGI program, this has the effect of sending a DDS object back to the client program. Either an entire DDS or a constrained DDS may be sent.
| out | The output stream to which the DAS is to be sent. |
| dds | The DDS to send back to a client. |
| eval | A reference to the ConstraintEvaluator to use. |
| constrained | If this argument is true, evaluate the current constraint expression and send the `constrained DDS' back to the client. |
| anc_location | The directory in which the external DAS file resides. |
| with_mime_headers | If true (the default) send MIME headers. |
Definition at line 286 of file ResponseBuilder.cc.
References libdap::dods_dds, libdap::ConstraintEvaluator::functional_expression(), libdap::DDS::get_dap_version(), libdap::last_modified_time(), libdap::ConstraintEvaluator::parse_constraint(), libdap::DDS::print(), libdap::DDS::print_constrained(), libdap::set_mime_text(), and libdap::x_plain.

| void libdap::ResponseBuilder::send_ddx | ( | ostream & | out, |
| DDS & | dds, | ||
| ConstraintEvaluator & | eval, | ||
| bool | with_mime_headers = true |
||
| ) | const [virtual] |
Send the DDX response. The DDX never contains data, instead it holds a reference to a Blob response which is used to get the data values. The DDS and DAS objects are built using code that already exists in the servers.
| dds | The dataset's DDS with attributes in the variables. |
| eval | A reference to the ConstraintEvaluator to use. |
| out | Destination |
| with_mime_headers | If true, include the MIME headers in the response. Defaults to true. |
Definition at line 427 of file ResponseBuilder.cc.
References libdap::dap4_ddx, libdap::ConstraintEvaluator::functional_expression(), libdap::DDS::get_dap_version(), libdap::last_modified_time(), libdap::ConstraintEvaluator::parse_constraint(), libdap::DDS::print_xml(), libdap::set_mime_text(), and libdap::x_plain.

| void libdap::ResponseBuilder::set_ce | ( | string | _ce | ) | [virtual] |
Definition at line 158 of file ResponseBuilder.cc.
References libdap::www2id().

| void libdap::ResponseBuilder::set_dataset_name | ( | const string | _dataset | ) | [virtual] |
Definition at line 208 of file ResponseBuilder.cc.
References libdap::www2id().

| void libdap::ResponseBuilder::set_mime_binary | ( | ostream & | strm, |
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain, |
||
| const time_t | last_modified = 0, |
||
| const string & | protocol = "" |
||
| ) | const |
Write an HTTP 1.0 response header for our binary response document (i.e., the DataDDS object).
| strm | Write the MIME header to this stream. |
| type | The type of this this response. Defaults to application/octet-stream. |
| ver | The version string; denotes the libdap implementation version. |
| enc | How is this response encoded? Can be plain or deflate or the x_... versions of those. Default is x_plain. |
| last_modified | The time to use for the Last-Modified header value. Default is zero which means use the current time. |
Definition at line 609 of file ResponseBuilder.cc.
References CRLF, DVR, libdap::rfc822_date(), and libdap::x_plain.

| void libdap::ResponseBuilder::set_mime_data_boundary | ( | ostream & | out, |
| const string & | boundary, | ||
| const string & | cid, | ||
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain |
||
| ) | const |
Definition at line 685 of file ResponseBuilder.cc.
References CRLF, and libdap::x_plain.
| void libdap::ResponseBuilder::set_mime_ddx_boundary | ( | ostream & | out, |
| const string & | boundary, | ||
| const string & | start, | ||
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain |
||
| ) | const |
Definition at line 672 of file ResponseBuilder.cc.
References CRLF, and libdap::x_plain.
| void libdap::ResponseBuilder::set_mime_error | ( | ostream & | strm, |
| int | code = 404, |
||
| const string & | reason = "Dataset not found", |
||
| const string & | protocol = "" |
||
| ) | const |
Generate an HTTP 1.0 response header for an Error object.
| strm | Write the MIME header to this stream. |
| code | HTTP 1.0 response code. Should be 400, ... 500, ... |
| reason | Reason string of the HTTP 1.0 response header. |
| version | The version string; denotes the DAP spec and implementation version. |
Definition at line 704 of file ResponseBuilder.cc.
References CRLF, DVR, and libdap::rfc822_date().

| void libdap::ResponseBuilder::set_mime_html | ( | ostream & | strm, |
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain, |
||
| const time_t | last_modified = 0, |
||
| const string & | protocol = "" |
||
| ) | const |
Generate an HTTP 1.0 response header for a html document.
| strm | Write the MIME header to this stream. |
| type | The type of this this response. |
| ver | The version string; denotes the libdap implementation version. |
| enc | How is this response encoded? Can be plain or deflate or the x_... versions of those. Default is x_plain. |
| last_modified | The time to use for the Last-Modified header value. Default is zero which means use the current time. |
Definition at line 561 of file ResponseBuilder.cc.
References CRLF, libdap::dods_error, DVR, libdap::rfc822_date(), and libdap::x_plain.

| void libdap::ResponseBuilder::set_mime_multipart | ( | ostream & | out, |
| const string & | boundary, | ||
| const string & | start, | ||
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain, |
||
| const time_t | last_modified = 0, |
||
| const string & | protocol = "" |
||
| ) | const |
Definition at line 640 of file ResponseBuilder.cc.
References CRLF, DVR, libdap::rfc822_date(), and libdap::x_plain.

| void libdap::ResponseBuilder::set_mime_text | ( | ostream & | strm, |
| ObjectType | type = unknown_type, |
||
| EncodingType | enc = x_plain, |
||
| const time_t | last_modified = 0, |
||
| const string & | protocol = "" |
||
| ) | const |
Generate an HTTP 1.0 response header for a text document. This is used when returning a serialized DAS or DDS object.
| strm | Write the MIME header to this stream. |
| type | The type of this this response. Defaults to application/octet-stream. |
| ver | The version string; denotes the libdap implementation version. |
| enc | How is this response encoded? Can be plain or deflate or the x_... versions of those. Default is x_plain. |
| last_modified | The time to use for the Last-Modified header value. Default is zero which means use the current time. |
Definition at line 511 of file ResponseBuilder.cc.
References CRLF, libdap::dap4_ddx, libdap::dods_error, DVR, libdap::rfc822_date(), and libdap::x_plain.

| void libdap::ResponseBuilder::set_timeout | ( | int | t = 0 | ) |
Set the server's timeout value. A value of zero (the default) means no timeout.
| t | Server timeout in seconds. Default is zero (no timeout). |
Definition at line 217 of file ResponseBuilder.cc.
friend class ResponseBuilderTest [friend] |
Definition at line 63 of file ResponseBuilder.h.
string libdap::ResponseBuilder::d_ce [protected] |
Definition at line 67 of file ResponseBuilder.h.
string libdap::ResponseBuilder::d_dataset [protected] |
Definition at line 66 of file ResponseBuilder.h.
string libdap::ResponseBuilder::d_default_protocol [protected] |
Definition at line 69 of file ResponseBuilder.h.
int libdap::ResponseBuilder::d_timeout [protected] |
Definition at line 68 of file ResponseBuilder.h.