Go to the documentation of this file.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 #include <vector>
00035
00036 using std::vector ;
00037
00038 #ifndef response_h
00039 #include "Response.h"
00040 #endif
00041
00042 #ifndef _debug_h
00043 #include "debug.h"
00044 #endif
00045
00046 namespace libdap
00047 {
00048
00049 extern int dods_keep_temps;
00050
00051 extern void close_temp(FILE *s, const string &name);
00052
00059 class HTTPResponse : public Response
00060 {
00061 private:
00062 vector<string> *d_headers;
00063 string d_file;
00064
00065 protected:
00068 HTTPResponse()
00069 {}
00070 HTTPResponse(const HTTPResponse &rs) : Response(rs)
00071 {}
00072 HTTPResponse &operator=(const HTTPResponse &)
00073 {
00074 throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
00075 }
00077
00078 public:
00095 HTTPResponse(FILE *s, int status, vector<string> *h, const string &temp_file)
00096 : Response(s, status), d_headers(h), d_file(temp_file)
00097 {
00098 DBG(cerr << "Headers: " << endl);
00099 DBGN(copy(d_headers->begin(), d_headers->end(),
00100 ostream_iterator<string>(cerr, "\n")));
00101 DBGN(cerr << "end of headers." << endl);
00102 }
00103
00107 virtual ~HTTPResponse()
00108 {
00109 DBG(cerr << "Freeing HTTPConnect resources (" + d_file + ")... ");
00110
00111 if (!dods_keep_temps && !d_file.empty()) {
00112 close_temp(get_stream(), d_file);
00113 set_stream(0);
00114 }
00115
00116 delete d_headers; d_headers = 0;
00117
00118 DBGN(cerr << endl);
00119 }
00122 virtual vector<string> *get_headers() const
00123 {
00124 return d_headers;
00125 }
00126 virtual string get_file() const
00127 {
00128 return d_file;
00129 }
00131
00134 virtual void set_headers(vector<string> *h)
00135 {
00136 d_headers = h;
00137 }
00139 };
00140
00141 }
00142
00143 #endif // http_response_h