Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
CurlTool Struct Reference

A tool for making http(s) requests and responses. More...

#include <curl_tools.h>

Public Member Functions

void FreeCurlTool (CurlTool *curl_p)
 Free a CurlTool. More...
 
bool SetSSLEngine (CurlTool *curl_p, const char *cryptograph_engine_name_s)
 Set the cryptographic engine to use. More...
 
bool AddCurlCallback (CurlTool *curl_tool_p, curl_write_callback callback_fn, void *callback_data_p)
 Add a callback to write the HTTP response for this CURL object to the given buffer. More...
 
bool SetUriForCurlTool (CurlTool *tool_p, const char *const uri_s)
 Set the URI that the CurlTool will try to get the html data from. More...
 
CURLcode RunCurlTool (CurlTool *tool_p)
 Run a CurlTool. More...
 
bool SetCurlToolForJSONPost (CurlTool *tool_p)
 Set up a CurlTool to do a JSON post when it is run. More...
 
const char * GetCurlToolData (CurlTool *const tool_p)
 Get the downloaded data from a CurlTool. More...
 
size_t GetCurlToolDataSize (CurlTool *const tool_p)
 Get the size in bytes of the downloaded data from a CurlTool. More...
 
bool MakeRemoteJSONCallFromCurlTool (CurlTool *tool_p, const json_t *req_p)
 Send a JSON request using a CurlTool. More...
 
bool SetCurlToolHeader (CurlTool *tool_p, const char *key_s, const char *value_s)
 Add a key value pair to the request header that a CurlTool will send when it is run. More...
 
bool SetCurlToolAuth (CurlTool *tool_p, const char *username_s, const char *password_s)
 
void ClearCurlToolAuth (CurlTool *tool_p)
 
char * GetURLEscapedString (CurlTool *tool_p, const char *src_s)
 Get the URL encoded version of a string. More...
 
void FreeURLEscapedString (char *value_s)
 Free a previously allocated string created by GetURLEscapedString. More...
 

Detailed Description

A tool for making http(s) requests and responses.

A datatype that uses CURL to perform http(s) requests and responses.

Member Function Documentation

◆ FreeCurlTool()

void FreeCurlTool ( CurlTool curl_p)

Free a CurlTool.

Parameters
curl_pThe CurlTool to free.

◆ SetSSLEngine()

bool SetSSLEngine ( CurlTool curl_p,
const char *  cryptograph_engine_name_s 
)

Set the cryptographic engine to use.

Parameters
curl_pThe CurlTool instance to set the SSL engine for.
cryptograph_engine_name_sThe name of the cryptographic engine to use. For the valid names see the CURL documentation.
Returns
true if the SSL engine name was set successfully, false otherwise.

◆ AddCurlCallback()

bool AddCurlCallback ( CurlTool curl_tool_p,
curl_write_callback  callback_fn,
void *  callback_data_p 
)

Add a callback to write the HTTP response for this CURL object to the given buffer.

Parameters
buffer_pThe ByteBuffer which will store the CURL object's response. *
curl_pThe CurlTool object to add the callback for.
Returns
true if the CurlTool was updated successfully, false otherwise.

◆ SetUriForCurlTool()

bool SetUriForCurlTool ( CurlTool tool_p,
const char *const  uri_s 
)

Set the URI that the CurlTool will try to get the html data from.

Parameters
tool_pThe CurlTool to update.
uri_sThe URI to set the CurlTool for.
Returns
true if the CurlTool was updated successfully, false otherwise.

◆ RunCurlTool()

CURLcode RunCurlTool ( CurlTool tool_p)

Run a CurlTool.

This will get the CurlTool to get all of the data from its given URI.

Parameters
tool_pThe CurlTool to run.
Returns
CURLE_OK if successful or an error code upon failure.

◆ SetCurlToolForJSONPost()

bool SetCurlToolForJSONPost ( CurlTool tool_p)

Set up a CurlTool to do a JSON post when it is run.

Parameters
tool_pThe CurlTool to update.
Returns
true if the CurlTool was updated successfully, false otherwise.

◆ GetCurlToolData()

const char * GetCurlToolData ( CurlTool *const  tool_p)

Get the downloaded data from a CurlTool.

If the CurlTool has been run successfully, this will get a read-only version of the downloaded data. RunCurlTool() must have been run prior to this.

Parameters
tool_pThe CurlTool to get the data from.
Returns
The downloaded data or NULL upon error.
See also
RunCurlTool

◆ GetCurlToolDataSize()

size_t GetCurlToolDataSize ( CurlTool *const  tool_p)

Get the size in bytes of the downloaded data from a CurlTool.

If the CurlTool has been run successfully, this will get the length of the downloaded data. RunCurlTool() must have been run prior to this.

Parameters
tool_pThe CurlTool to get the length from.
Returns
The length of the downloaded data.
See also
RunCurlTool

◆ MakeRemoteJSONCallFromCurlTool()

bool MakeRemoteJSONCallFromCurlTool ( CurlTool tool_p,
const json_t *  req_p 
)

Send a JSON request using a CurlTool.

Parameters
tool_pThe CurlTool to use.
req_pThe json data to send.
Returns
true if the CurlTool made the request and received a response successfully. The resultant data can be retrieved using GetCurlToolData. If the call was unsuccessful, then false will be returned.
See also
GetCurlToolData

◆ SetCurlToolHeader()

bool SetCurlToolHeader ( CurlTool tool_p,
const char *  key_s,
const char *  value_s 
)

Add a key value pair to the request header that a CurlTool will send when it is run.

Parameters
tool_pThe CurlTool to add the header to
key_sThe key to add. This will be copied so this value does not need to stay in scope.
value_sThe value to add. This will be copied so this value does not need to stay in scope.
Returns
true if the header values were set successfully, false otherwise.

◆ SetCurlToolAuth()

bool SetCurlToolAuth ( CurlTool tool_p,
const char *  username_s,
const char *  password_s 
)

◆ ClearCurlToolAuth()

void ClearCurlToolAuth ( CurlTool tool_p)

◆ GetURLEscapedString()

char * GetURLEscapedString ( CurlTool tool_p,
const char *  src_s 
)

Get the URL encoded version of a string.

Parameters
tool_pThe CurlTool to use to generate the URL encoded string.
src_sThe string to encode.
Returns
The URL encoded version of the input string. This must be freed with FreeURLEscapedString.
See also
GetURLEscapedString

◆ FreeURLEscapedString()

void FreeURLEscapedString ( char *  value_s)

Free a previously allocated string created by GetURLEscapedString.

Parameters
value_sThe string to free. This must have been created by GetURLEscapedString.
See also
GetURLEscapedString

The documentation for this struct was generated from the following file: