libdap++  Updated for version 3.14.0
libdap::HTTPConnect Class Reference

#include <HTTPConnect.h>

Collaboration diagram for libdap::HTTPConnect:
Collaboration graph

Public Member Functions

HTTPResponsefetch_url (const string &url)
 
 HTTPConnect (RCReader *rcr, bool use_cpp=false)
 
bool is_cache_enabled ()
 
void set_accept_deflate (bool defalte)
 
void set_cache_enabled (bool enabled)
 
void set_cookie_jar (const string &cookie_jar)
 
void set_credentials (const string &u, const string &p)
 
void set_use_cpp_streams (bool use_cpp_streams)
 
void set_xdap_protocol (int major, int minor)
 
bool use_cpp_streams () const
 
virtual ~HTTPConnect ()
 

Protected Member Functions

Suppress default methods

These methods are not supported and are implemented here as protected methods to suppress the C++-supplied default versions (which will break this object).

 HTTPConnect ()
 
 HTTPConnect (const HTTPConnect &)
 
HTTPConnectoperator= (const HTTPConnect &)
 

Friends

class HTTPConnectTest
 
class ParseHeader
 
size_t save_raw_http_header (void *ptr, size_t size, size_t nmemb, void *http_connect)
 

Detailed Description

Use the CURL library to dereference a HTTP URL. Scan the response for headers used by DAP 2.0 and extract their values. The body of the response is made available using a FILE pointer.

Author
jhrg

Definition at line 72 of file HTTPConnect.h.

Constructor & Destructor Documentation

libdap::HTTPConnect::HTTPConnect ( )
protected
libdap::HTTPConnect::HTTPConnect ( const HTTPConnect )
protected
libdap::HTTPConnect::~HTTPConnect ( )
virtual

Definition at line 585 of file HTTPConnect.cc.

References DBG2.

Member Function Documentation

HTTPResponse * libdap::HTTPConnect::fetch_url ( const string &  url)

Dereference a URL. This method dereferences a URL and stores the result (i.e., it formulates an HTTP request and processes the HTTP server's response). After this method is successfully called, the value of is_response_present() will be true and the methods get_response_headers(), type() and server_version() may be called.

Parameters
urlThe URL to dereference.
Returns
A pointer to the stream.
Exceptions
ErrorThrown if the URL could not be dereferenced.
InternalErrThrown if a temporary file to hold the response could not be opened.

Definition at line 615 of file HTTPConnect.cc.

References libdap::HTTPResponse::get_headers(), libdap::Response::get_status(), is_cache_enabled(), ParseHeader, libdap::Response::set_protocol(), libdap::Response::set_type(), libdap::Response::set_version(), and libdap::HTTPResponse::transform_to_cpp().

Referenced by main(), libdap::D4Connect::request_dap4_data(), libdap::Connect::request_das(), libdap::Connect::request_das_url(), libdap::Connect::request_data(), libdap::Connect::request_data_ddx(), libdap::Connect::request_data_ddx_url(), libdap::Connect::request_data_url(), libdap::Connect::request_dds(), libdap::Connect::request_dds_url(), libdap::Connect::request_ddx(), libdap::Connect::request_ddx_url(), libdap::D4Connect::request_dmr(), libdap::Connect::request_protocol(), and libdap::Connect::request_version().

Here is the call graph for this function:

bool libdap::HTTPConnect::is_cache_enabled ( )
inline

Return the current state of the HTTP cache.

Definition at line 156 of file HTTPConnect.h.

References libdap::HTTPCache::is_cache_enabled().

Referenced by fetch_url(), libdap::D4Connect::is_cache_enabled(), and libdap::Connect::is_cache_enabled().

Here is the call graph for this function:

HTTPConnect& libdap::HTTPConnect::operator= ( const HTTPConnect )
protected
void libdap::HTTPConnect::set_accept_deflate ( bool  deflate)

Set the accept deflate property. If true, the DAP client announces to a server that it can accept responses compressed using the deflate algorithm. This property is automatically set using a value from the .dodsrc configuration file. This method provides a way to override that behavior.

Note
If the configuration file is not present or does not include a value for this property, it is set to false.
Parameters
deflateTrue sets the accept deflate property, False clears it.

Definition at line 988 of file HTTPConnect.cc.

References DBG, and libdap::deflate.

Referenced by main(), libdap::D4Connect::set_accept_deflate(), and libdap::Connect::set_accept_deflate().

void libdap::HTTPConnect::set_cache_enabled ( bool  enabled)
inline

Set the state of the HTTP cache. By default, the HTTP cache is enabled or disabled using the value of the USE_CACHE property in the .dodsrc file. Use this method to set the state from within a program.

Parameters
enabledTrue to use the cache, False to disable.

Definition at line 150 of file HTTPConnect.h.

References libdap::HTTPCache::set_cache_enabled().

Referenced by libdap::D4Connect::set_cache_enabled(), and libdap::Connect::set_cache_enabled().

Here is the call graph for this function:

void libdap::HTTPConnect::set_cookie_jar ( const string &  cookie_jar)
inline

Set the cookie jar. This function sets the name of a file used to store cookies returned by servers. This will help with things like single sign on systems.

Parameters
cookie_jarThe pathname to the file that stores cookies. If this is the empty string saving cookies is disabled.

Definition at line 143 of file HTTPConnect.h.

void libdap::HTTPConnect::set_credentials ( const string &  u,
const string &  p 
)

Set the credentials for responding to challenges while dereferencing URLs. Alternatively, these can be embedded in the URL. This method provides a way for clients of HTTPConnect to get credentials from users (say using a pop up dialog) and to not hack the URL to pass that information to libcurl. Note that the 'credentials in the URL' scheme is part of the URL standard.

This method does nothing if u, the username, is empty.

Parameters
uThe username.
pThe password.
Exceptions
InternalErrThe credentials could not be registered with libcurl.
See also
extract_auth_info()

Definition at line 1054 of file HTTPConnect.cc.

Referenced by libdap::D4Connect::set_credentials(), and libdap::Connect::set_credentials().

void libdap::HTTPConnect::set_use_cpp_streams ( bool  use_cpp_streams)
inline

Definition at line 135 of file HTTPConnect.h.

References use_cpp_streams().

Here is the call graph for this function:

void libdap::HTTPConnect::set_xdap_protocol ( int  major,
int  minor 
)

Set the xdap_accept property/HTTP-header. This sets the value of the DAP which the client advertises to servers that it understands. The information (client protocol major and minor versions) are recorded in the instance and the information is sent to servers using the XDAP-Accept HTTP request header.

Parameters
majorThe dap client major protocol version
minorThe dap client minor protocol version

Definition at line 1017 of file HTTPConnect.cc.

References DBG.

Referenced by libdap::D4Connect::set_xdap_protocol(), and libdap::Connect::set_xdap_protocol().

bool libdap::HTTPConnect::use_cpp_streams ( ) const
inline

Definition at line 134 of file HTTPConnect.h.

Referenced by set_use_cpp_streams().

Friends And Related Function Documentation

friend class HTTPConnectTest
friend

Definition at line 111 of file HTTPConnect.h.

friend class ParseHeader
friend

Definition at line 112 of file HTTPConnect.h.

Referenced by fetch_url().

size_t save_raw_http_header ( void *  ptr,
size_t  size,
size_t  nmemb,
void *  http_connect 
)
friend

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