26#ifndef http_response_h
27#define http_response_h
46extern int dods_keep_temps;
47extern void close_temp(FILE *s,
const string &name);
55class HTTPResponse :
public Response {
57 std::vector<std::string> *d_headers;
64 HTTPResponse(
const HTTPResponse &rs);
65 HTTPResponse &operator=(
const HTTPResponse &);
85 HTTPResponse(FILE *s,
int status, std::vector<std::string> *h,
const std::string &temp_file)
86 : Response(s, status), d_headers(h), d_file(temp_file) {
87 DBG(cerr <<
"Headers: " << endl);
88 DBGN(copy(d_headers->begin(), d_headers->end(), ostream_iterator<string>(cerr,
"\n")));
89 DBGN(cerr <<
"end of headers." << endl);
101 HTTPResponse(std::fstream *s,
int status, std::vector<std::string> *h,
const std::string &temp_file)
102 : Response(s, status), d_headers(h), d_file(temp_file) {
103 DBG(cerr <<
"Headers: " << endl);
104 DBGN(copy(d_headers->begin(), d_headers->end(), ostream_iterator<string>(cerr,
"\n")));
105 DBGN(cerr <<
"end of headers." << endl);
112 DBG(cerr <<
"Freeing HTTPConnect resources (" + d_file +
")... ");
117 delete get_cpp_stream();
120 if (!dods_keep_temps && !d_file.empty()) {
125 (void)unlink(d_file.c_str());
127 long res = unlink(d_file.c_str());
128 if (res != 0)
throw InternalErr(__FILE__, __LINE__,
"!FAIL! " + long_to_string(res));
148 set_cpp_stream(
new std::fstream(d_file.c_str(), std::ios::in | std::ios::binary));
153 virtual std::vector<std::string> *get_headers()
const {
return d_headers; }
154 virtual std::string get_file()
const {
return d_file; }
159 virtual void set_headers(std::vector<std::string> *h) { d_headers = h; }
160 virtual void set_file(
const std::string &n) { d_file = n; }
HTTPResponse(std::fstream *s, int status, std::vector< std::string > *h, const std::string &temp_file)
Build a HTTPResponse using a cpp fstream When working with DAP4 responses, use C++ streams for I/0.
HTTPResponse(FILE *s, int status, std::vector< std::string > *h, const std::string &temp_file)
A class for software fault reporting.
top level DAP object to house generic methods
void close_temp(FILE *s, const string &name)