Logo ROOT  
Reference Guide
Loading...
Searching...
No Matches
ROOT::Internal::RCurlConnection Class Reference

Encapsulates a curl easy handle and provides an interface to send HTTP HEAD and (multi-)range queries.

Definition at line 43 of file RCurlConnection.hxx.

Classes

struct  RStatus
 Return value for both HEAD and GET requests. More...
struct  RUserRange
 Caller-provided byte-range of the remote resource together with a pointer to a buffer. More...

Public Member Functions

 RCurlConnection (const RCurlConnection &other)=delete
 RCurlConnection (const std::string &url)
 RCurlConnection (RCurlConnection &&other)
 ~RCurlConnection ()
void ClearCredentials ()
EHTTPCredentialsType GetCredentialsType () const
const std::string & GetEscapedUrl () const
std::size_t GetMaxNRangesPerRequest () const
RCurlConnectionoperator= (const RCurlConnection &other)=delete
RCurlConnectionoperator= (RCurlConnection &&other)
RStatus SendHeadReq (std::uint64_t &remoteSize)
 Checks if the resource exists and if it does, return the value of the content-length header as size.
RStatus SendRangesReq (std::size_t N, RUserRange *ranges)
 Reads the given ranges from the remote resource.
void SetCredentials (const RS3Credentials &credentials)
void SetCredentialsFromEnvironment ()
 Sets the credentials from process environment variables.
void SetMaxNRangesPerRequest (std::size_t val)

Static Public Member Functions

static int GetCurlVersion ()
 Used for testing.

Static Public Attributes

static constexpr std::uint64_t kUnknownSize = static_cast<std::uint64_t>(-1)
 Returned by SendHeadReq() if the HTTP response contains no content-length header.

Private Member Functions

void Perform (RStatus &status)
void SetOptions ()
void SetupErrorBuffer ()
RResult< voidSetUrl (const std::string &url)

Private Attributes

std::unique_ptr< RHTTPCredentialsfCredentials
std::unique_ptr< char[]> fErrorBuffer
 For use by libcurl.
std::string fEscapedUrl
 The URL provided in the constructor escaped according to standard rules.
voidfHandle = nullptr
 the CURL easy handle corresponding to this connection
std::size_t fMaxNRangesPerReqest = 0
 If set to zero, automatically adjust: try with all given ranges and as long as the number of ranges is too large, half it.

#include <ROOT/RCurlConnection.hxx>

Constructor & Destructor Documentation

◆ RCurlConnection() [1/3]

ROOT::Internal::RCurlConnection::RCurlConnection ( const std::string & url)
explicit

Definition at line 587 of file RCurlConnection.cxx.

◆ ~RCurlConnection()

ROOT::Internal::RCurlConnection::~RCurlConnection ( )

Definition at line 606 of file RCurlConnection.cxx.

◆ RCurlConnection() [2/3]

ROOT::Internal::RCurlConnection::RCurlConnection ( const RCurlConnection & other)
delete

◆ RCurlConnection() [3/3]

ROOT::Internal::RCurlConnection::RCurlConnection ( RCurlConnection && other)

Definition at line 612 of file RCurlConnection.cxx.

Member Function Documentation

◆ ClearCredentials()

void ROOT::Internal::RCurlConnection::ClearCredentials ( )

Definition at line 874 of file RCurlConnection.cxx.

◆ GetCredentialsType()

ROOT::Internal::EHTTPCredentialsType ROOT::Internal::RCurlConnection::GetCredentialsType ( ) const

Definition at line 892 of file RCurlConnection.cxx.

◆ GetCurlVersion()

int ROOT::Internal::RCurlConnection::GetCurlVersion ( )
static

Used for testing.

Definition at line 582 of file RCurlConnection.cxx.

◆ GetEscapedUrl()

const std::string & ROOT::Internal::RCurlConnection::GetEscapedUrl ( ) const
inline

Definition at line 120 of file RCurlConnection.hxx.

◆ GetMaxNRangesPerRequest()

std::size_t ROOT::Internal::RCurlConnection::GetMaxNRangesPerRequest ( ) const
inline

Definition at line 123 of file RCurlConnection.hxx.

◆ operator=() [1/2]

RCurlConnection & ROOT::Internal::RCurlConnection::operator= ( const RCurlConnection & other)
delete

◆ operator=() [2/2]

RCurlConnection & ROOT::Internal::RCurlConnection::operator= ( RCurlConnection && other)

◆ Perform()

void ROOT::Internal::RCurlConnection::Perform ( RStatus & status)
private

Definition at line 691 of file RCurlConnection.cxx.

◆ SendHeadReq()

ROOT::Internal::RCurlConnection::RStatus ROOT::Internal::RCurlConnection::SendHeadReq ( std::uint64_t & remoteSize)

Checks if the resource exists and if it does, return the value of the content-length header as size.

Definition at line 730 of file RCurlConnection.cxx.

◆ SendRangesReq()

ROOT::Internal::RCurlConnection::RStatus ROOT::Internal::RCurlConnection::SendRangesReq ( std::size_t N,
RUserRange * ranges )

Reads the given ranges from the remote resource.

The ranges can be in any order and also overlapping. They will be transformed in optimized HTTP ranges for a multi-range request. Ranges past the resource size are valid (but won't receive any data). No limit on the number of ranges; if fMaxNRangesPerReqest is zero, a valid batching of requests into multiple multi-range requests takes place automatically. The fNBytesRecv member of the ranges is only well-defined on success.

Definition at line 759 of file RCurlConnection.cxx.

◆ SetCredentials()

void ROOT::Internal::RCurlConnection::SetCredentials ( const RS3Credentials & credentials)

Definition at line 852 of file RCurlConnection.cxx.

◆ SetCredentialsFromEnvironment()

void ROOT::Internal::RCurlConnection::SetCredentialsFromEnvironment ( )

Sets the credentials from process environment variables.

Currently supported

  • S3_ACCESS_KEY, S3_SECRET_KEY, S3_REGION If the environment variables are not found, clear any credentials from the connection.

Definition at line 900 of file RCurlConnection.cxx.

◆ SetMaxNRangesPerRequest()

void ROOT::Internal::RCurlConnection::SetMaxNRangesPerRequest ( std::size_t val)
inline

Definition at line 122 of file RCurlConnection.hxx.

◆ SetOptions()

void ROOT::Internal::RCurlConnection::SetOptions ( )
private

Definition at line 638 of file RCurlConnection.cxx.

◆ SetupErrorBuffer()

void ROOT::Internal::RCurlConnection::SetupErrorBuffer ( )
private

Definition at line 630 of file RCurlConnection.cxx.

◆ SetUrl()

ROOT::RResult< void > ROOT::Internal::RCurlConnection::SetUrl ( const std::string & url)
private

Definition at line 663 of file RCurlConnection.cxx.

Member Data Documentation

◆ fCredentials

std::unique_ptr<RHTTPCredentials> ROOT::Internal::RCurlConnection::fCredentials
private

Definition at line 67 of file RCurlConnection.hxx.

◆ fErrorBuffer

std::unique_ptr<char[]> ROOT::Internal::RCurlConnection::fErrorBuffer
private

For use by libcurl.

Definition at line 74 of file RCurlConnection.hxx.

◆ fEscapedUrl

std::string ROOT::Internal::RCurlConnection::fEscapedUrl
private

The URL provided in the constructor escaped according to standard rules.

Definition at line 73 of file RCurlConnection.hxx.

◆ fHandle

void* ROOT::Internal::RCurlConnection::fHandle = nullptr
private

the CURL easy handle corresponding to this connection

Definition at line 68 of file RCurlConnection.hxx.

◆ fMaxNRangesPerReqest

std::size_t ROOT::Internal::RCurlConnection::fMaxNRangesPerReqest = 0
private

If set to zero, automatically adjust: try with all given ranges and as long as the number of ranges is too large, half it.

If set to zero and automatic reduction of the number of requests is necessary, the number of requests that works will be saved for further requests with this object.

Definition at line 72 of file RCurlConnection.hxx.

◆ kUnknownSize

std::uint64_t ROOT::Internal::RCurlConnection::kUnknownSize = static_cast<std::uint64_t>(-1)
staticconstexpr

Returned by SendHeadReq() if the HTTP response contains no content-length header.

Definition at line 83 of file RCurlConnection.hxx.

Collaboration diagram for ROOT::Internal::RCurlConnection:
[legend]

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