00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef http_response_h
00027 #define http_response_h
00028
00029 #include <cstdio>
00030 #include <string>
00031 #include <iostream>
00032 #include <algorithm>
00033 #include <iterator>
00034
00035 #ifndef response_h
00036 #include "Response.h"
00037 #endif
00038
00039 #ifndef _debug_h
00040 #include "debug.h"
00041 #endif
00042
00043 namespace libdap
00044 {
00045
00046 extern int dods_keep_temps;
00047 extern void close_temp(FILE *s, const string &name);
00048
00055 class HTTPResponse : public Response
00056 {
00057 private:
00058 vector<string> *d_headers;
00059 string d_file;
00060
00061 protected:
00064 HTTPResponse()
00065 {}
00066 HTTPResponse(const HTTPResponse &rs) : Response(rs)
00067 {}
00068 HTTPResponse &operator=(const HTTPResponse &)
00069 {
00070 throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
00071 }
00073
00074 public:
00091 HTTPResponse(FILE *s, int status, vector<string> *h, const string &temp_file)
00092 : Response(s, status), d_headers(h), d_file(temp_file)
00093 {
00094 DBG(cerr << "Headers: " << endl);
00095 DBGN(copy(d_headers->begin(), d_headers->end(),
00096 ostream_iterator<string>(cerr, "\n")));
00097 DBGN(cerr << "end of headers." << endl);
00098 }
00099
00103 virtual ~HTTPResponse()
00104 {
00105 DBG(cerr << "Freeing HTTPConnect resources (" + d_file + ")... ");
00106
00107 if (!dods_keep_temps && !d_file.empty()) {
00108 close_temp(get_stream(), d_file);
00109 set_stream(0);
00110 }
00111
00112 delete d_headers; d_headers = 0;
00113
00114 DBGN(cerr << endl);
00115 }
00118 virtual vector<string> *get_headers() const
00119 {
00120 return d_headers;
00121 }
00123
00126 virtual void set_headers(vector<string> *h)
00127 {
00128 d_headers = h;
00129 }
00131 };
00132
00133 }
00134
00135 #endif // http_response_h