26 #ifndef http_response_h 27 #define http_response_h 47 extern int dods_keep_temps;
48 extern void close_temp(FILE *s,
const string &name);
59 std::vector<std::string> *d_headers;
87 HTTPResponse(FILE *s,
int status, std::vector<std::string> *h,
const std::string &temp_file)
88 :
Response(s, status), d_headers(h), d_file(temp_file)
90 DBG(cerr <<
"Headers: " << endl);
91 DBGN(copy(d_headers->begin(), d_headers->end(),
92 ostream_iterator<string>(cerr,
"\n")));
93 DBGN(cerr <<
"end of headers." << endl);
105 HTTPResponse(std::fstream *s,
int status, std::vector<std::string> *h,
const std::string &temp_file)
106 :
Response(s, status), d_headers(h), d_file(temp_file)
108 DBG(cerr <<
"Headers: " << endl);
109 DBGN(copy(d_headers->begin(), d_headers->end(),
110 ostream_iterator<string>(cerr,
"\n")));
111 DBGN(cerr <<
"end of headers." << endl);
119 DBG(cerr <<
"Freeing HTTPConnect resources (" + d_file +
")... ");
124 delete get_cpp_stream();
127 if (!dods_keep_temps && !d_file.empty()) {
133 (void) unlink(d_file.c_str());
135 long res = unlink(d_file.c_str());
136 if (res != 0)
throw InternalErr(__FILE__, __LINE__,
"!FAIL! " + long_to_string(res));
156 set_cpp_stream(
new std::fstream(d_file.c_str(), std::ios::in|std::ios::binary));
161 virtual std::vector<std::string> *get_headers()
const {
return d_headers; }
162 virtual std::string get_file()
const {
return d_file; }
167 virtual void set_headers(std::vector<std::string> *h) { d_headers = h; }
168 virtual void set_file(
const std::string &n) { d_file = n; }
174 #endif // http_response_h
top level DAP object to house generic methods
A class for software fault reporting.
void close_temp(FILE *s, const string &name)
HTTPResponse(FILE *s, int status, std::vector< std::string > *h, const std::string &temp_file)
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...