pianod2
multisource multiuser scriptable networked music player
Classes | Macros | Functions
httpclient.cpp File Reference

HTTP client request provider. More...

#include <config.h>
#include <string>
#include <sstream>
#include <vector>
#include <unordered_map>
#include <cassert>
#include <cstring>
#include <ostream>
#include <iomanip>
#include "httpclient.h"
Include dependency graph for httpclient.cpp:

Classes

class  CurlSList
 

Macros

#define set_and_check(option, value)
 

Functions

static const char * request_type (HttpClient::RequestType type)
 
static void dump_string_dict (std::ostream &target, const char *title, const HttpClient::StringDict &dict)
 Render the contents of a dictionary to a file/stream. More...
 
static bool add_cookies (HttpClient::StringDict &dict, const std::string &text)
 Parse a set-cookie header and cookies to a dictionary. More...
 
static size_t header_callback (char *buffer, size_t size, size_t nitems, void *userdata)
 Callback to collect headers from CURL. More...
 
static size_t receive_callback (char *buffer, size_t size, size_t nitems, void *userdata)
 callback to assembed received response from CURL. More...
 
static CurlSList assemble_headers (const HttpClient::Request &request)
 
static std::string assemble_url (CURL *session, const HttpClient::Request &request)
 

Detailed Description

HTTP client request provider.

Macro Definition Documentation

◆ set_and_check

#define set_and_check (   option,
  value 
)
Value:
if ((code = curl_easy_setopt (session, (option), (value))) != CURLE_OK) { \
throw Exception ("curl_easy_setopt", code, #option); \
}
uint32_t value
Definition: audiooutput.cpp:68

Function Documentation

◆ add_cookies()

static bool add_cookies ( HttpClient::StringDict dict,
const std::string &  text 
)
static

Parse a set-cookie header and cookies to a dictionary.

Parameters
dictThe dictionary to which to add cookies.
textThe header text containing cookies.
Here is the caller graph for this function:

◆ assemble_headers()

static CurlSList assemble_headers ( const HttpClient::Request request)
static
Here is the caller graph for this function:

◆ assemble_url()

static std::string assemble_url ( CURL *  session,
const HttpClient::Request request 
)
static
Here is the caller graph for this function:

◆ dump_string_dict()

static void dump_string_dict ( std::ostream &  target,
const char *  title,
const HttpClient::StringDict dict 
)
static

Render the contents of a dictionary to a file/stream.

Parameters
targetThe stream to which to send the dictionary.
titleDescriptive text for the dictionary.
dictThe dictionary to render.
Here is the caller graph for this function:

◆ header_callback()

static size_t header_callback ( char *  buffer,
size_t  size,
size_t  nitems,
void *  userdata 
)
static

Callback to collect headers from CURL.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ receive_callback()

static size_t receive_callback ( char *  buffer,
size_t  size,
size_t  nitems,
void *  userdata 
)
static

callback to assembed received response from CURL.

Here is the caller graph for this function:

◆ request_type()

static const char* request_type ( HttpClient::RequestType  type)
static
Here is the caller graph for this function: