bes Updated for version 3.20.13
http::RemoteResource Class Reference

#include <RemoteResource.h>

Collaboration diagram for http::RemoteResource:
Collaboration graph

Public Member Functions

rapidjson::Document get_as_json ()
 get_as_json() This function returns the cached resource parsed into a JSON document.
 
std::string get_http_response_header (const std::string header_name)
 
std::string get_response_as_string ()
 
std::string getCacheFileName ()
 
std::vector< std::string > * getResponseHeaders ()
 
std::string getType ()
 
 RemoteResource (std::shared_ptr< http::url > target_url, const std::string &uid="", long long expires_interval=HttpCache::getCacheExpiresTime())
 
void retrieveResource ()
 
void retrieveResource (const std::map< std::string, std::string > &content_filters)
 
virtual ~RemoteResource ()
 

Friends

class RemoteResourceTest
 

Detailed Description

This class encapsulates a remote resource available via HTTP GET. It will retrieve the content of the resource and place it in a local disk cache for rapid (subsequent) access. It can be configure to use a proxy server for the outgoing requests.

Definition at line 55 of file RemoteResource.h.

Constructor & Destructor Documentation

◆ RemoteResource() [1/2]

http::RemoteResource::RemoteResource ( )
inlineprotected

Definition at line 145 of file RemoteResource.h.

◆ RemoteResource() [2/2]

http::RemoteResource::RemoteResource ( std::shared_ptr< http::url target_url,
const std::string &  uid = "",
long long  expires_interval = HttpCache::getCacheExpiresTime() 
)

Definition at line 68 of file RemoteResource.cc.

◆ ~RemoteResource()

http::RemoteResource::~RemoteResource ( )
virtual

Releases any memory resources and also any existing cache file locks for the cached resource. ( Closes the file descriptor opened when retrieveResource() was called.)

Definition at line 207 of file RemoteResource.cc.

Member Function Documentation

◆ get_as_json()

rapidjson::Document http::RemoteResource::get_as_json ( )

get_as_json() This function returns the cached resource parsed into a JSON document.

Parameters
target_urlThe URL to dereference. @TODO Move this to ../curl_utils.cc (Requires moving the rapidjson lib too)
Returns
JSON document parsed from the response document returned by target_url

Definition at line 712 of file RemoteResource.cc.

◆ get_http_response_header()

std::string http::RemoteResource::get_http_response_header ( const std::string  header_name)

Returns the value of the requested HTTP response header. Evaluation is case-insensitive. If the requested header_name is not found the empty string is returned.

Definition at line 609 of file RemoteResource.cc.

◆ get_response_as_string()

std::string http::RemoteResource::get_response_as_string ( )

Returns cache file content in a string..

Definition at line 675 of file RemoteResource.cc.

◆ getCacheFileName()

std::string http::RemoteResource::getCacheFileName ( )

Returns the (read-locked) cache file name on the local system in which the content of the remote resource is stored. Deleting of the instance of this class will release the read-lock.

Definition at line 229 of file RemoteResource.cc.

◆ getResponseHeaders()

vector< string > * http::RemoteResource::getResponseHeaders ( )

Returns a std::vector of HTTP headers received along with the response from the request for the remote resource..

Definition at line 722 of file RemoteResource.cc.

◆ getType()

std::string http::RemoteResource::getType ( )
inline

Returns the DAP type std::string of the RemoteHttpResource

Returns
Returns the DAP type std::string used by the BES Containers.

Definition at line 165 of file RemoteResource.h.

◆ retrieveResource() [1/2]

void http::RemoteResource::retrieveResource ( )

This method will check the cache for the resource. If it's not there then it will lock the cache and retrieve the remote resource content using HTTP GET.

When this method returns the RemoteResource object is fully initialized and the cache file name for the resource is available along with an open file descriptor for the (now read-locked) cache file.

Definition at line 244 of file RemoteResource.cc.

◆ retrieveResource() [2/2]

void http::RemoteResource::retrieveResource ( const std::map< std::string, std::string > &  content_filters)

This method will check the cache for the resource. If it's not there then it will lock the cache and retrieve the remote resource content using HTTP GET.

When this method returns the RemoteHttpResource object is fully initialized and the cache file name for the resource is available along with an open file descriptor for the (now read-locked) cache file.

Parameters
uid
template_key
replace_value

Definition at line 260 of file RemoteResource.cc.

Friends And Related Function Documentation

◆ RemoteResourceTest

friend class RemoteResourceTest
friend

Definition at line 57 of file RemoteResource.h.


The documentation for this class was generated from the following files: