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 <stdio.h>
00030
00031 #include <string>
00032 #include <iostream>
00033 #include <algorithm>
00034 #include <iterator>
00035
00036 #ifndef response_h
00037 #include "Response.h"
00038 #endif
00039
00040 #ifndef _debug_h
00041 #include "debug.h"
00042 #endif
00043
00044 extern int dods_keep_temps;
00045 extern void close_temp(FILE *s, const string &name);
00046
00053 class HTTPResponse : public Response
00054 {
00055 private:
00056 vector<string> *d_headers;
00057 string d_file;
00058
00059 protected:
00062 HTTPResponse()
00063 {}
00064 HTTPResponse(const HTTPResponse &rs) : Response(rs)
00065 {}
00066 HTTPResponse &operator=(const HTTPResponse &)
00067 {
00068 throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
00069 }
00071
00072 public:
00089 HTTPResponse(FILE *s, int status, vector<string> *h, const string &temp_file)
00090 : Response(s, status), d_headers(h), d_file(temp_file)
00091 {
00092 DBG(cerr << "Headers: " << endl);
00093 DBGN(copy(d_headers->begin(), d_headers->end(),
00094 ostream_iterator<string>(cerr, "\n")));
00095 DBGN(cerr << "end of headers." << endl);
00096 }
00097
00101 virtual ~HTTPResponse()
00102 {
00103 DBG(cerr << "Freeing HTTPConnect resources (" + d_file + ")... ");
00104
00105 if (!dods_keep_temps && !d_file.empty()) {
00106 close_temp(get_stream(), d_file);
00107 set_stream(0);
00108 }
00109
00110 delete d_headers; d_headers = 0;
00111
00112 DBGN(cerr << endl);
00113 }
00116 virtual vector<string> *get_headers() const
00117 {
00118 return d_headers;
00119 }
00121
00124 virtual void set_headers(vector<string> *h)
00125 {
00126 d_headers = h;
00127 }
00129 };
00130
00131 #endif // http_response_h