#include <HTTPResponse.h>
Encapsulate an http response. Instead of directly returning the FILE pointer from which a response is read and vector of headers, return an instance of this object.
- Todo
- Maybe refactor so that the header parsing code is here and not in HTTPConnect?
Definition at line 56 of file HTTPResponse.h.
◆ HTTPResponse() [1/2]
libdap::HTTPResponse::HTTPResponse |
( |
FILE * | s, |
|
|
int | status, |
|
|
std::vector< std::string > * | h, |
|
|
const std::string & | temp_file ) |
|
inline |
Build an HTTPResponse object. An instance of this class is used to return an HTTP response (body and headers). If the response is really from a remote server, the current HTTP code stores the body in a temporary file and the headers in a vector<string> object. This class will delete those resources when its destructor is called. If the response does not have a temporary file that needs to be deleted (say it actually comes from a local cache or was read directly into memory), the temp file should be set to "".
- Parameters
-
s | FILE * to the response. Read the response body from this stream. |
status | The HTTP response status code. |
h | Response headers. This class will delete the pointer when the instance that contains it is destroyed. |
temp_file | Name a the temporary file that holds the response body; this file is deleted when this instance is deleted. |
Definition at line 87 of file HTTPResponse.h.
◆ HTTPResponse() [2/2]
libdap::HTTPResponse::HTTPResponse |
( |
std::fstream * | s, |
|
|
int | status, |
|
|
std::vector< std::string > * | h, |
|
|
const std::string & | temp_file ) |
|
inline |
Build a HTTPResponse using a cpp fstream When working with DAP4 responses, use C++ streams for I/0.
- Todo
- Decide on how the temp files fit into DAP4
- Parameters
-
Definition at line 105 of file HTTPResponse.h.
◆ ~HTTPResponse()
virtual libdap::HTTPResponse::~HTTPResponse |
( |
| ) |
|
|
inlinevirtual |
When an instance is destroyed, free the temporary resources: the temp_file and headers are deleted. If the tmp file name is "", it is not deleted.
Definition at line 117 of file HTTPResponse.h.
◆ get_cpp_stream()
virtual std::istream * libdap::Response::get_cpp_stream |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ get_file()
virtual std::string libdap::HTTPResponse::get_file |
( |
| ) |
const |
|
inlinevirtual |
◆ get_headers()
virtual std::vector< std::string > * libdap::HTTPResponse::get_headers |
( |
| ) |
const |
|
inlinevirtual |
◆ get_protocol()
virtual std::string libdap::Response::get_protocol |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ get_status()
virtual int libdap::Response::get_status |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ get_stream()
virtual FILE * libdap::Response::get_stream |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ get_type()
virtual ObjectType libdap::Response::get_type |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ get_version()
virtual std::string libdap::Response::get_version |
( |
| ) |
const |
|
inlinevirtualinherited |
◆ set_cpp_stream()
virtual void libdap::Response::set_cpp_stream |
( |
std::istream * | s | ) |
|
|
inlinevirtualinherited |
◆ set_file()
virtual void libdap::HTTPResponse::set_file |
( |
const std::string & | n | ) |
|
|
inlinevirtual |
◆ set_headers()
virtual void libdap::HTTPResponse::set_headers |
( |
std::vector< std::string > * | h | ) |
|
|
inlinevirtual |
◆ set_protocol()
virtual void libdap::Response::set_protocol |
( |
const std::string & | p | ) |
|
|
inlinevirtualinherited |
◆ set_status()
virtual void libdap::Response::set_status |
( |
int | s | ) |
|
|
inlinevirtualinherited |
◆ set_stream()
virtual void libdap::Response::set_stream |
( |
FILE * | s | ) |
|
|
inlinevirtualinherited |
◆ set_type()
virtual void libdap::Response::set_type |
( |
ObjectType | o | ) |
|
|
inlinevirtualinherited |
◆ set_version()
virtual void libdap::Response::set_version |
( |
const std::string & | v | ) |
|
|
inlinevirtualinherited |
◆ transform_to_cpp()
void libdap::HTTPResponse::transform_to_cpp |
( |
| ) |
|
|
inline |
Build a new HTTPResponse object that works with C++ streams. Assume that the FILE* references a disk file.
- Returns
Definition at line 151 of file HTTPResponse.h.
The documentation for this class was generated from the following file: