946 lines
66 KiB
HTML
946 lines
66 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.16"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
<title>mastodonpp: mastodonpp::CURLWrapper Class Reference</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">mastodonpp
|
|
 <span id="projectnumber">0.3.0</span>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.16 -->
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
/* @license-end */
|
|
</script>
|
|
<script type="text/javascript" src="menudata.js"></script>
|
|
<script type="text/javascript" src="menu.js"></script>
|
|
<script type="text/javascript">
|
|
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */
|
|
$(function() {
|
|
initMenu('',true,false,'search.php','Search');
|
|
$(document).ready(function() { init_search(); });
|
|
});
|
|
/* @license-end */</script>
|
|
<div id="main-nav"></div>
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div id="nav-path" class="navpath">
|
|
<ul>
|
|
<li class="navelem"><a class="el" href="namespacemastodonpp.html">mastodonpp</a></li><li class="navelem"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a></li> </ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div class="header">
|
|
<div class="summary">
|
|
<a href="#pub-methods">Public Member Functions</a> |
|
|
<a href="#pro-methods">Protected Member Functions</a> |
|
|
<a href="#pro-attribs">Protected Attributes</a> |
|
|
<a href="classmastodonpp_1_1CURLWrapper-members.html">List of all members</a> </div>
|
|
<div class="headertitle">
|
|
<div class="title">mastodonpp::CURLWrapper Class Reference</div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
|
|
<p>Handles the details of network connections.
|
|
<a href="classmastodonpp_1_1CURLWrapper.html#details">More...</a></p>
|
|
|
|
<p><code>#include <<a class="el" href="curl__wrapper_8hpp_source.html">mastodonpp/curl_wrapper.hpp</a>></code></p>
|
|
<div class="dynheader">
|
|
Inheritance diagram for mastodonpp::CURLWrapper:</div>
|
|
<div class="dyncontent">
|
|
<div class="center">
|
|
<img src="classmastodonpp_1_1CURLWrapper.png" usemap="#mastodonpp::CURLWrapper_map" alt=""/>
|
|
<map id="mastodonpp::CURLWrapper_map" name="mastodonpp::CURLWrapper_map">
|
|
<area href="classmastodonpp_1_1Connection.html" title="Represents a connection to an instance. Used for requests." alt="mastodonpp::Connection" shape="rect" coords="0,56,209,80"/>
|
|
<area href="classmastodonpp_1_1Instance.html" title="Holds the access data of an instance." alt="mastodonpp::Instance" shape="rect" coords="219,56,428,80"/>
|
|
<area href="classmastodonpp_1_1Instance_1_1ObtainToken.html" title="Simplifies obtaining an OAuth 2.0 Bearer Access Token." alt="mastodonpp::Instance::ObtainToken" shape="rect" coords="438,56,647,80"/>
|
|
</map>
|
|
</div></div>
|
|
<table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
|
|
Public Member Functions</h2></td></tr>
|
|
<tr class="memitem:a736572303fbec7a307514e611e6a468c"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">CURLWrapper</a> ()</td></tr>
|
|
<tr class="memdesc:a736572303fbec7a307514e611e6a468c"><td class="mdescLeft"> </td><td class="mdescRight">Initializes curl and sets up connection. <a href="classmastodonpp_1_1CURLWrapper.html#a736572303fbec7a307514e611e6a468c">More...</a><br /></td></tr>
|
|
<tr class="separator:a736572303fbec7a307514e611e6a468c"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a108929a9985c76a8e2cd1f531ac6d321"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a108929a9985c76a8e2cd1f531ac6d321">CURLWrapper</a> (const <a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &other)=delete</td></tr>
|
|
<tr class="memdesc:a108929a9985c76a8e2cd1f531ac6d321"><td class="mdescLeft"> </td><td class="mdescRight">Copy constructor. <a href="classmastodonpp_1_1CURLWrapper.html#a108929a9985c76a8e2cd1f531ac6d321">More...</a><br /></td></tr>
|
|
<tr class="separator:a108929a9985c76a8e2cd1f531ac6d321"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a4d79b9a4525ac4b4b8954ccc794af0f9"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a4d79b9a4525ac4b4b8954ccc794af0f9">CURLWrapper</a> (<a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &&other) noexcept=delete</td></tr>
|
|
<tr class="memdesc:a4d79b9a4525ac4b4b8954ccc794af0f9"><td class="mdescLeft"> </td><td class="mdescRight">Move constructor. <a href="classmastodonpp_1_1CURLWrapper.html#a4d79b9a4525ac4b4b8954ccc794af0f9">More...</a><br /></td></tr>
|
|
<tr class="separator:a4d79b9a4525ac4b4b8954ccc794af0f9"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a350f7061c9cb54cb5992ae983db3fc19"><td class="memItemLeft" align="right" valign="top">virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a350f7061c9cb54cb5992ae983db3fc19">~CURLWrapper</a> () noexcept</td></tr>
|
|
<tr class="memdesc:a350f7061c9cb54cb5992ae983db3fc19"><td class="mdescLeft"> </td><td class="mdescRight">Cleans up curl and connection. <a href="classmastodonpp_1_1CURLWrapper.html#a350f7061c9cb54cb5992ae983db3fc19">More...</a><br /></td></tr>
|
|
<tr class="separator:a350f7061c9cb54cb5992ae983db3fc19"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a5f29b7f4d0b58f70bc96f362cdaa4d0a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a5f29b7f4d0b58f70bc96f362cdaa4d0a">operator=</a> (const <a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &other)=delete</td></tr>
|
|
<tr class="memdesc:a5f29b7f4d0b58f70bc96f362cdaa4d0a"><td class="mdescLeft"> </td><td class="mdescRight">Copy assignment operator. <a href="classmastodonpp_1_1CURLWrapper.html#a5f29b7f4d0b58f70bc96f362cdaa4d0a">More...</a><br /></td></tr>
|
|
<tr class="separator:a5f29b7f4d0b58f70bc96f362cdaa4d0a"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a506cb49c00a63ef4b9d51d0d52c203dc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> & </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a506cb49c00a63ef4b9d51d0d52c203dc">operator=</a> (<a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> &&other) noexcept=delete</td></tr>
|
|
<tr class="memdesc:a506cb49c00a63ef4b9d51d0d52c203dc"><td class="mdescLeft"> </td><td class="mdescRight">Move assignment operator. <a href="classmastodonpp_1_1CURLWrapper.html#a506cb49c00a63ef4b9d51d0d52c203dc">More...</a><br /></td></tr>
|
|
<tr class="separator:a506cb49c00a63ef4b9d51d0d52c203dc"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a2b7aaf03245a0730eeb464802168aded"><td class="memItemLeft" align="right" valign="top">CURL * </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a2b7aaf03245a0730eeb464802168aded">get_curl_easy_handle</a> ()</td></tr>
|
|
<tr class="memdesc:a2b7aaf03245a0730eeb464802168aded"><td class="mdescLeft"> </td><td class="mdescRight">Returns pointer to the CURL easy handle. <a href="classmastodonpp_1_1CURLWrapper.html#a2b7aaf03245a0730eeb464802168aded">More...</a><br /></td></tr>
|
|
<tr class="separator:a2b7aaf03245a0730eeb464802168aded"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a11a543a0821a275dfce1ad7a0e68b17f"><td class="memItemLeft" align="right" valign="top">string </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a11a543a0821a275dfce1ad7a0e68b17f">escape_url</a> (const string_view url) const</td></tr>
|
|
<tr class="memdesc:a11a543a0821a275dfce1ad7a0e68b17f"><td class="mdescLeft"> </td><td class="mdescRight">URL encodes the given string. <a href="classmastodonpp_1_1CURLWrapper.html#a11a543a0821a275dfce1ad7a0e68b17f">More...</a><br /></td></tr>
|
|
<tr class="separator:a11a543a0821a275dfce1ad7a0e68b17f"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:aed6d09b5c32d71276a851ddf321b5891"><td class="memItemLeft" align="right" valign="top">string </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#aed6d09b5c32d71276a851ddf321b5891">unescape_url</a> (const string_view url) const</td></tr>
|
|
<tr class="memdesc:aed6d09b5c32d71276a851ddf321b5891"><td class="mdescLeft"> </td><td class="mdescRight">URL decodes the given string . <a href="classmastodonpp_1_1CURLWrapper.html#aed6d09b5c32d71276a851ddf321b5891">More...</a><br /></td></tr>
|
|
<tr class="separator:aed6d09b5c32d71276a851ddf321b5891"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a0059ecb78b53c4b3c941b19f8dc897f7"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a0059ecb78b53c4b3c941b19f8dc897f7">setup_connection_properties</a> (string_view proxy, string_view access_token, string_view cainfo, string_view useragent)</td></tr>
|
|
<tr class="memdesc:a0059ecb78b53c4b3c941b19f8dc897f7"><td class="mdescLeft"> </td><td class="mdescRight">Set some properties of the connection. <a href="classmastodonpp_1_1CURLWrapper.html#a0059ecb78b53c4b3c941b19f8dc897f7">More...</a><br /></td></tr>
|
|
<tr class="separator:a0059ecb78b53c4b3c941b19f8dc897f7"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
|
|
Protected Member Functions</h2></td></tr>
|
|
<tr class="memitem:adc8808c3fad5397176f6755b09ee0be6"><td class="memItemLeft" align="right" valign="top"><a class="el" href="structmastodonpp_1_1answer__type.html">answer_type</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#adc8808c3fad5397176f6755b09ee0be6">make_request</a> (const <a class="el" href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100">http_method</a> &method, string uri, const <a class="el" href="namespacemastodonpp.html#af8b3b89118adeccc71c54dfd36c987f6">parametermap</a> &parameters)</td></tr>
|
|
<tr class="memdesc:adc8808c3fad5397176f6755b09ee0be6"><td class="mdescLeft"> </td><td class="mdescRight">Make a HTTP request. <a href="classmastodonpp_1_1CURLWrapper.html#adc8808c3fad5397176f6755b09ee0be6">More...</a><br /></td></tr>
|
|
<tr class="separator:adc8808c3fad5397176f6755b09ee0be6"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a04b3919cfb38716c5a032337e442db95"><td class="memItemLeft" align="right" valign="top">string & </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a04b3919cfb38716c5a032337e442db95">get_buffer</a> ()</td></tr>
|
|
<tr class="memdesc:a04b3919cfb38716c5a032337e442db95"><td class="mdescLeft"> </td><td class="mdescRight">Returns a reference to the buffer libcurl writes into. <a href="classmastodonpp_1_1CURLWrapper.html#a04b3919cfb38716c5a032337e442db95">More...</a><br /></td></tr>
|
|
<tr class="separator:a04b3919cfb38716c5a032337e442db95"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a892a4fc3d048798fa8e2584545b91861"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a892a4fc3d048798fa8e2584545b91861">cancel_stream</a> ()</td></tr>
|
|
<tr class="memdesc:a892a4fc3d048798fa8e2584545b91861"><td class="mdescLeft"> </td><td class="mdescRight">Cancel the stream. <a href="classmastodonpp_1_1CURLWrapper.html#a892a4fc3d048798fa8e2584545b91861">More...</a><br /></td></tr>
|
|
<tr class="separator:a892a4fc3d048798fa8e2584545b91861"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a1564a42794ef7a9d170b725063ef504d"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a1564a42794ef7a9d170b725063ef504d">set_proxy</a> (string_view proxy)</td></tr>
|
|
<tr class="memdesc:a1564a42794ef7a9d170b725063ef504d"><td class="mdescLeft"> </td><td class="mdescRight">Set the proxy to use. <a href="classmastodonpp_1_1CURLWrapper.html#a1564a42794ef7a9d170b725063ef504d">More...</a><br /></td></tr>
|
|
<tr class="separator:a1564a42794ef7a9d170b725063ef504d"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:a7a229cf9eae6bd03adfc2fdfdff62d88"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#a7a229cf9eae6bd03adfc2fdfdff62d88">set_access_token</a> (const string_view access_token)</td></tr>
|
|
<tr class="memdesc:a7a229cf9eae6bd03adfc2fdfdff62d88"><td class="mdescLeft"> </td><td class="mdescRight">Set OAuth 2.0 Bearer Access Token. <a href="classmastodonpp_1_1CURLWrapper.html#a7a229cf9eae6bd03adfc2fdfdff62d88">More...</a><br /></td></tr>
|
|
<tr class="separator:a7a229cf9eae6bd03adfc2fdfdff62d88"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:af3f2bd4dea7c289d590fe19889360444"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#af3f2bd4dea7c289d590fe19889360444">set_cainfo</a> (string_view path)</td></tr>
|
|
<tr class="memdesc:af3f2bd4dea7c289d590fe19889360444"><td class="mdescLeft"> </td><td class="mdescRight">Set path to Certificate Authority (CA) bundle. <a href="classmastodonpp_1_1CURLWrapper.html#af3f2bd4dea7c289d590fe19889360444">More...</a><br /></td></tr>
|
|
<tr class="separator:af3f2bd4dea7c289d590fe19889360444"><td class="memSeparator" colspan="2"> </td></tr>
|
|
<tr class="memitem:ae3b1445f9b94b1f7677d3cac6d538612"><td class="memItemLeft" align="right" valign="top"><a id="ae3b1445f9b94b1f7677d3cac6d538612"></a>
|
|
void </td><td class="memItemRight" valign="bottom"><b>set_useragent</b> (string_view useragent)</td></tr>
|
|
<tr class="separator:ae3b1445f9b94b1f7677d3cac6d538612"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table><table class="memberdecls">
|
|
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
|
|
Protected Attributes</h2></td></tr>
|
|
<tr class="memitem:aeb3171d955832b8062dc02b4ac67d195"><td class="memItemLeft" align="right" valign="top">mutex </td><td class="memItemRight" valign="bottom"><a class="el" href="classmastodonpp_1_1CURLWrapper.html#aeb3171d955832b8062dc02b4ac67d195">buffer_mutex</a></td></tr>
|
|
<tr class="memdesc:aeb3171d955832b8062dc02b4ac67d195"><td class="mdescLeft"> </td><td class="mdescRight">Mutex for <a class="el" href="classmastodonpp_1_1CURLWrapper.html#a04b3919cfb38716c5a032337e442db95" title="Returns a reference to the buffer libcurl writes into.">get_buffer</a> a.k.a. _curl_buffer_body. <a href="classmastodonpp_1_1CURLWrapper.html#aeb3171d955832b8062dc02b4ac67d195">More...</a><br /></td></tr>
|
|
<tr class="separator:aeb3171d955832b8062dc02b4ac67d195"><td class="memSeparator" colspan="2"> </td></tr>
|
|
</table>
|
|
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
|
|
<div class="textblock"><p>Handles the details of network connections. </p>
|
|
<p>You don't need to use this.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
</div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
|
|
<a id="a736572303fbec7a307514e611e6a468c"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a736572303fbec7a307514e611e6a468c">◆ </a></span>CURLWrapper() <span class="overload">[1/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mastodonpp::CURLWrapper::CURLWrapper </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Initializes curl and sets up connection. </p>
|
|
<p>The first time an instance of <a class="el" href="classmastodonpp_1_1CURLWrapper.html" title="Handles the details of network connections.">CURLWrapper</a> is created, it calls <code>curl_global_init</code>, which is not thread-safe. For more information consult <a href="https://curl.haxx.se/libcurl/c/curl_global_init.html">curl_global_init(3)</a>.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00042"></a><span class="lineno"> 42</span>  : _curl_buffer_error{}</div>
|
|
<div class="line"><a name="l00043"></a><span class="lineno"> 43</span>  , _stream_cancelled(<span class="keyword">false</span>)</div>
|
|
<div class="line"><a name="l00044"></a><span class="lineno"> 44</span> {</div>
|
|
<div class="line"><a name="l00045"></a><span class="lineno"> 45</span>  <span class="keywordflow">if</span> (curlwrapper_instances == 0)</div>
|
|
<div class="line"><a name="l00046"></a><span class="lineno"> 46</span>  {</div>
|
|
<div class="line"><a name="l00047"></a><span class="lineno"> 47</span>  curl_global_init(CURL_GLOBAL_ALL); <span class="comment">// NOLINT(hicpp-signed-bitwise)</span></div>
|
|
<div class="line"><a name="l00048"></a><span class="lineno"> 48</span>  }</div>
|
|
<div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  ++curlwrapper_instances;</div>
|
|
<div class="line"><a name="l00050"></a><span class="lineno"> 50</span>  debuglog << <span class="stringliteral">"CURLWrapper instances: "</span> << curlwrapper_instances << <span class="stringliteral">" (+1)\n"</span>;</div>
|
|
<div class="line"><a name="l00051"></a><span class="lineno"> 51</span>  </div>
|
|
<div class="line"><a name="l00052"></a><span class="lineno"> 52</span>  _connection = curl_easy_init();</div>
|
|
<div class="line"><a name="l00053"></a><span class="lineno"> 53</span>  setup_curl();</div>
|
|
<div class="line"><a name="l00054"></a><span class="lineno"> 54</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a108929a9985c76a8e2cd1f531ac6d321"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a108929a9985c76a8e2cd1f531ac6d321">◆ </a></span>CURLWrapper() <span class="overload">[2/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mastodonpp::CURLWrapper::CURLWrapper </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> & </td>
|
|
<td class="paramname"><em>other</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">delete</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Copy constructor. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a4d79b9a4525ac4b4b8954ccc794af0f9"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a4d79b9a4525ac4b4b8954ccc794af0f9">◆ </a></span>CURLWrapper() <span class="overload">[3/3]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mastodonpp::CURLWrapper::CURLWrapper </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> && </td>
|
|
<td class="paramname"><em>other</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">delete</span><span class="mlabel">noexcept</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Move constructor. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a350f7061c9cb54cb5992ae983db3fc19"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a350f7061c9cb54cb5992ae983db3fc19">◆ </a></span>~CURLWrapper()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mastodonpp::CURLWrapper::~CURLWrapper </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">virtual</span><span class="mlabel">noexcept</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Cleans up curl and connection. </p>
|
|
<p>Calls <code>curl_global_cleanup</code>, which is not thread-safe. For more information consult <a href="https://curl.haxx.se/libcurl/c/curl_global_cleanup.html">curl_global_cleanup(3)</a>.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00056"></a><span class="lineno"> 56</span> {</div>
|
|
<div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  curl_easy_cleanup(_connection);</div>
|
|
<div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  </div>
|
|
<div class="line"><a name="l00059"></a><span class="lineno"> 59</span>  --curlwrapper_instances;</div>
|
|
<div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  debuglog << <span class="stringliteral">"CURLWrapper instances: "</span> << curlwrapper_instances << <span class="stringliteral">" (-1)\n"</span>;</div>
|
|
<div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  <span class="keywordflow">if</span> (curlwrapper_instances == 0)</div>
|
|
<div class="line"><a name="l00062"></a><span class="lineno"> 62</span>  {</div>
|
|
<div class="line"><a name="l00063"></a><span class="lineno"> 63</span>  curl_global_cleanup();</div>
|
|
<div class="line"><a name="l00064"></a><span class="lineno"> 64</span>  }</div>
|
|
<div class="line"><a name="l00065"></a><span class="lineno"> 65</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<h2 class="groupheader">Member Function Documentation</h2>
|
|
<a id="a892a4fc3d048798fa8e2584545b91861"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a892a4fc3d048798fa8e2584545b91861">◆ </a></span>cancel_stream()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mastodonpp::CURLWrapper::cancel_stream </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Cancel the stream. </p>
|
|
<p>The stream will be cancelled, usually whithin a second. The <a class="el" href="structmastodonpp_1_1answer__type.html#a7c5582c4500034c0ea36ab1694944139">curl_error_code </a> of the answer will be set to 42 (<code>CURLE_ABORTED_BY_CALLBACK</code>).</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  {</div>
|
|
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  _stream_cancelled = <span class="keyword">true</span>;</div>
|
|
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a11a543a0821a275dfce1ad7a0e68b17f"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a11a543a0821a275dfce1ad7a0e68b17f">◆ </a></span>escape_url()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">string mastodonpp::CURLWrapper::escape_url </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const string_view </td>
|
|
<td class="paramname"><em>url</em></td><td>)</td>
|
|
<td> const</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>URL encodes the given string. </p>
|
|
<p>For more information consult <a href="https://curl.haxx.se/libcurl/c/curl_easy_escape.html">curl_easy_escape(3)</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">url</td><td>String to escape.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The escaped string or {} if it failed.</dd></dl>
|
|
<dl class="section since"><dt>Since</dt><dd>0.3.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  {</div>
|
|
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  <span class="keywordtype">char</span> *cbuf{curl_easy_escape(_connection, url.data(),</div>
|
|
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  static_cast<int>(url.size()))};</div>
|
|
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  <span class="keywordtype">string</span> sbuf{cbuf};</div>
|
|
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  curl_free(cbuf);</div>
|
|
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordflow">return</span> sbuf;</div>
|
|
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a04b3919cfb38716c5a032337e442db95"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a04b3919cfb38716c5a032337e442db95">◆ </a></span>get_buffer()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">string& mastodonpp::CURLWrapper::get_buffer </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns a reference to the buffer libcurl writes into. </p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  {</div>
|
|
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  <span class="keywordflow">return</span> _curl_buffer_body;</div>
|
|
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a2b7aaf03245a0730eeb464802168aded"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a2b7aaf03245a0730eeb464802168aded">◆ </a></span>get_curl_easy_handle()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">CURL* mastodonpp::CURLWrapper::get_curl_easy_handle </td>
|
|
<td>(</td>
|
|
<td class="paramname"></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Returns pointer to the CURL easy handle. </p>
|
|
<p>You can use this handle to set or modify curl options. For more information consult <a href="https://curl.haxx.se/libcurl/c/curl_easy_setopt.html">curl_easy_setopt(3)</a>.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  {</div>
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  <span class="keywordflow">return</span> _connection;</div>
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="adc8808c3fad5397176f6755b09ee0be6"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#adc8808c3fad5397176f6755b09ee0be6">◆ </a></span>make_request()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="structmastodonpp_1_1answer__type.html">answer_type</a> mastodonpp::CURLWrapper::make_request </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="el" href="namespacemastodonpp.html#a7d60fc71ad0fb1fbd467b37fe1f1f100">http_method</a> & </td>
|
|
<td class="paramname"><em>method</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">string </td>
|
|
<td class="paramname"><em>uri</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">const <a class="el" href="namespacemastodonpp.html#af8b3b89118adeccc71c54dfd36c987f6">parametermap</a> & </td>
|
|
<td class="paramname"><em>parameters</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Make a HTTP request. </p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">method</td><td>The HTTP method. </td></tr>
|
|
<tr><td class="paramname">uri</td><td>The full URI. </td></tr>
|
|
<tr><td class="paramname">parameters</td><td>A map of parameters.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00069"></a><span class="lineno"> 69</span> {</div>
|
|
<div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  _stream_cancelled = <span class="keyword">false</span>;</div>
|
|
<div class="line"><a name="l00071"></a><span class="lineno"> 71</span>  _curl_buffer_headers.clear();</div>
|
|
<div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  _curl_buffer_body.clear();</div>
|
|
<div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  </div>
|
|
<div class="line"><a name="l00074"></a><span class="lineno"> 74</span>  CURLcode code;</div>
|
|
<div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">switch</span> (method)</div>
|
|
<div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  {</div>
|
|
<div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <span class="keywordflow">case</span> http_method::GET:</div>
|
|
<div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  {</div>
|
|
<div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  add_parameters_to_uri(uri, parameters);</div>
|
|
<div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  curl_easy_setopt(_connection, CURLOPT_HTTPGET, 1L);</div>
|
|
<div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  </div>
|
|
<div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  }</div>
|
|
<div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keywordflow">case</span> http_method::POST:</div>
|
|
<div class="line"><a name="l00086"></a><span class="lineno"> 86</span>  {</div>
|
|
<div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <span class="keywordflow">if</span> (parameters.empty())</div>
|
|
<div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  {</div>
|
|
<div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00090"></a><span class="lineno"> 90</span>  curl_easy_setopt(_connection, CURLOPT_POST, 1L);</div>
|
|
<div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  }</div>
|
|
<div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  {</div>
|
|
<div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  curl_mime *mime{parameters_to_curl_mime(uri, parameters)};</div>
|
|
<div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);</div>
|
|
<div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  }</div>
|
|
<div class="line"><a name="l00098"></a><span class="lineno"> 98</span>  </div>
|
|
<div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00100"></a><span class="lineno"> 100</span>  }</div>
|
|
<div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="keywordflow">case</span> http_method::PATCH:</div>
|
|
<div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  {</div>
|
|
<div class="line"><a name="l00103"></a><span class="lineno"> 103</span>  <span class="keywordflow">if</span> (!parameters.empty())</div>
|
|
<div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  {</div>
|
|
<div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  curl_mime *mime{parameters_to_curl_mime(uri, parameters)};</div>
|
|
<div class="line"><a name="l00106"></a><span class="lineno"> 106</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00107"></a><span class="lineno"> 107</span>  curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);</div>
|
|
<div class="line"><a name="l00108"></a><span class="lineno"> 108</span>  }</div>
|
|
<div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  </div>
|
|
<div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00111"></a><span class="lineno"> 111</span>  code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, <span class="stringliteral">"PATCH"</span>);</div>
|
|
<div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  {</div>
|
|
<div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Failed to set URI"</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00115"></a><span class="lineno"> 115</span>  }</div>
|
|
<div class="line"><a name="l00116"></a><span class="lineno"> 116</span>  </div>
|
|
<div class="line"><a name="l00117"></a><span class="lineno"> 117</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00118"></a><span class="lineno"> 118</span>  }</div>
|
|
<div class="line"><a name="l00119"></a><span class="lineno"> 119</span>  <span class="keywordflow">case</span> http_method::PUT:</div>
|
|
<div class="line"><a name="l00120"></a><span class="lineno"> 120</span>  {</div>
|
|
<div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <span class="keywordflow">if</span> (!parameters.empty())</div>
|
|
<div class="line"><a name="l00122"></a><span class="lineno"> 122</span>  {</div>
|
|
<div class="line"><a name="l00123"></a><span class="lineno"> 123</span>  curl_mime *mime{parameters_to_curl_mime(uri, parameters)};</div>
|
|
<div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00125"></a><span class="lineno"> 125</span>  curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);</div>
|
|
<div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  }</div>
|
|
<div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  </div>
|
|
<div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, <span class="stringliteral">"PUT"</span>);</div>
|
|
<div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  {</div>
|
|
<div class="line"><a name="l00132"></a><span class="lineno"> 132</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Failed to set URI"</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  }</div>
|
|
<div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  </div>
|
|
<div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  }</div>
|
|
<div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keywordflow">case</span> http_method::DELETE:</div>
|
|
<div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  {</div>
|
|
<div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  <span class="keywordflow">if</span> (!parameters.empty())</div>
|
|
<div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  {</div>
|
|
<div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  curl_mime *mime{parameters_to_curl_mime(uri, parameters)};</div>
|
|
<div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  curl_easy_setopt(_connection, CURLOPT_MIMEPOST, mime);</div>
|
|
<div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  }</div>
|
|
<div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  </div>
|
|
<div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  code = curl_easy_setopt(_connection, CURLOPT_CUSTOMREQUEST, <span class="stringliteral">"DELETE"</span>);</div>
|
|
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  {</div>
|
|
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Failed to set URI"</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  }</div>
|
|
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  </div>
|
|
<div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  <span class="keywordflow">break</span>;</div>
|
|
<div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  }</div>
|
|
<div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  }</div>
|
|
<div class="line"><a name="l00156"></a><span class="lineno"> 156</span>  debuglog << <span class="stringliteral">"Making request to: "</span> << uri << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><a name="l00157"></a><span class="lineno"> 157</span>  </div>
|
|
<div class="line"><a name="l00158"></a><span class="lineno"> 158</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00159"></a><span class="lineno"> 159</span>  code = curl_easy_setopt(_connection, CURLOPT_URL, uri.data());</div>
|
|
<div class="line"><a name="l00160"></a><span class="lineno"> 160</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00161"></a><span class="lineno"> 161</span>  {</div>
|
|
<div class="line"><a name="l00162"></a><span class="lineno"> 162</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Failed to set URI"</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00163"></a><span class="lineno"> 163</span>  }</div>
|
|
<div class="line"><a name="l00164"></a><span class="lineno"> 164</span>  </div>
|
|
<div class="line"><a name="l00165"></a><span class="lineno"> 165</span>  answer_type answer;</div>
|
|
<div class="line"><a name="l00166"></a><span class="lineno"> 166</span>  code = curl_easy_perform(_connection);</div>
|
|
<div class="line"><a name="l00167"></a><span class="lineno"> 167</span>  <span class="keywordflow">if</span> (code == CURLE_OK</div>
|
|
<div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  || (code == CURLE_ABORTED_BY_CALLBACK && _stream_cancelled))</div>
|
|
<div class="line"><a name="l00169"></a><span class="lineno"> 169</span>  {</div>
|
|
<div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  <span class="keywordtype">long</span> http_status; <span class="comment">// NOLINT(google-runtime-int)</span></div>
|
|
<div class="line"><a name="l00171"></a><span class="lineno"> 171</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00172"></a><span class="lineno"> 172</span>  curl_easy_getinfo(_connection, CURLINFO_RESPONSE_CODE, &http_status);</div>
|
|
<div class="line"><a name="l00173"></a><span class="lineno"> 173</span>  answer.http_status = static_cast<uint16_t>(http_status);</div>
|
|
<div class="line"><a name="l00174"></a><span class="lineno"> 174</span>  debuglog << <span class="stringliteral">"HTTP status code: "</span> << http_status << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><a name="l00175"></a><span class="lineno"> 175</span>  </div>
|
|
<div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  answer.headers = _curl_buffer_headers;</div>
|
|
<div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  answer.body = _curl_buffer_body;</div>
|
|
<div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  }</div>
|
|
<div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordflow">else</span></div>
|
|
<div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  {</div>
|
|
<div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  answer.curl_error_code = static_cast<uint8_t>(code);</div>
|
|
<div class="line"><a name="l00182"></a><span class="lineno"> 182</span>  answer.error_message = _curl_buffer_error;</div>
|
|
<div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  debuglog << <span class="stringliteral">"libcurl error: "</span> << code << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  debuglog << _curl_buffer_error << <span class="charliteral">'\n'</span>;</div>
|
|
<div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  }</div>
|
|
<div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  </div>
|
|
<div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  <span class="keywordflow">return</span> answer;</div>
|
|
<div class="line"><a name="l00188"></a><span class="lineno"> 188</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a5f29b7f4d0b58f70bc96f362cdaa4d0a"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a5f29b7f4d0b58f70bc96f362cdaa4d0a">◆ </a></span>operator=() <span class="overload">[1/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a>& mastodonpp::CURLWrapper::operator= </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const <a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> & </td>
|
|
<td class="paramname"><em>other</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">delete</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Copy assignment operator. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a506cb49c00a63ef4b9d51d0d52c203dc"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a506cb49c00a63ef4b9d51d0d52c203dc">◆ </a></span>operator=() <span class="overload">[2/2]</span></h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a>& mastodonpp::CURLWrapper::operator= </td>
|
|
<td>(</td>
|
|
<td class="paramtype"><a class="el" href="classmastodonpp_1_1CURLWrapper.html">CURLWrapper</a> && </td>
|
|
<td class="paramname"><em>other</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">delete</span><span class="mlabel">noexcept</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Move assignment operator. </p>
|
|
|
|
</div>
|
|
</div>
|
|
<a id="a7a229cf9eae6bd03adfc2fdfdff62d88"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a7a229cf9eae6bd03adfc2fdfdff62d88">◆ </a></span>set_access_token()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mastodonpp::CURLWrapper::set_access_token </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const string_view </td>
|
|
<td class="paramname"><em>access_token</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set OAuth 2.0 Bearer Access Token. </p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00227"></a><span class="lineno"> 227</span> {</div>
|
|
<div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-signed-bitwise)</span></div>
|
|
<div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  CURLcode code{curl_easy_setopt(_connection, CURLOPT_XOAUTH2_BEARER,</div>
|
|
<div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  access_token.data())};</div>
|
|
<div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  {</div>
|
|
<div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Could not set authorization token."</span>,</div>
|
|
<div class="line"><a name="l00234"></a><span class="lineno"> 234</span>  _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00235"></a><span class="lineno"> 235</span>  }</div>
|
|
<div class="line"><a name="l00236"></a><span class="lineno"> 236</span>  </div>
|
|
<div class="line"><a name="l00237"></a><span class="lineno"> 237</span> <span class="preprocessor">#if (LIBCURL_VERSION_NUM < 0x073d00) // libcurl < 7.61.0.</span></div>
|
|
<div class="line"><a name="l00238"></a><span class="lineno"> 238</span> <span class="preprocessor">#define CURLAUTH_BEARER CURLAUTH_ANY</span></div>
|
|
<div class="line"><a name="l00239"></a><span class="lineno"> 239</span> <span class="preprocessor">#endif</span></div>
|
|
<div class="line"><a name="l00240"></a><span class="lineno"> 240</span>  </div>
|
|
<div class="line"><a name="l00241"></a><span class="lineno"> 241</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg, hicpp-signed-bitwise)</span></div>
|
|
<div class="line"><a name="l00242"></a><span class="lineno"> 242</span>  code = curl_easy_setopt(_connection, CURLOPT_HTTPAUTH, CURLAUTH_BEARER);</div>
|
|
<div class="line"><a name="l00243"></a><span class="lineno"> 243</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00244"></a><span class="lineno"> 244</span>  {</div>
|
|
<div class="line"><a name="l00245"></a><span class="lineno"> 245</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Could not set authorization token."</span>,</div>
|
|
<div class="line"><a name="l00246"></a><span class="lineno"> 246</span>  _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00247"></a><span class="lineno"> 247</span>  }</div>
|
|
<div class="line"><a name="l00248"></a><span class="lineno"> 248</span>  </div>
|
|
<div class="line"><a name="l00249"></a><span class="lineno"> 249</span>  debuglog << <span class="stringliteral">"Set authorization token.\n"</span>;</div>
|
|
<div class="line"><a name="l00250"></a><span class="lineno"> 250</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="af3f2bd4dea7c289d590fe19889360444"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#af3f2bd4dea7c289d590fe19889360444">◆ </a></span>set_cainfo()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mastodonpp::CURLWrapper::set_cainfo </td>
|
|
<td>(</td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>path</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set path to Certificate Authority (CA) bundle. </p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.3.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00253"></a><span class="lineno"> 253</span> {</div>
|
|
<div class="line"><a name="l00254"></a><span class="lineno"> 254</span>  CURLcode code{curl_easy_setopt(_connection, CURLOPT_CAINFO, path.data())};</div>
|
|
<div class="line"><a name="l00255"></a><span class="lineno"> 255</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00256"></a><span class="lineno"> 256</span>  {</div>
|
|
<div class="line"><a name="l00257"></a><span class="lineno"> 257</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Could not set CA info."</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00258"></a><span class="lineno"> 258</span>  }</div>
|
|
<div class="line"><a name="l00259"></a><span class="lineno"> 259</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a1564a42794ef7a9d170b725063ef504d"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a1564a42794ef7a9d170b725063ef504d">◆ </a></span>set_proxy()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mastodonpp::CURLWrapper::set_proxy </td>
|
|
<td>(</td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>proxy</em></td><td>)</td>
|
|
<td></td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set the proxy to use. </p>
|
|
<p>See <a href="https://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html">CURLOPT_PROXY(3)</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">proxy</td><td>Examples: "socks4a://127.0.0.1:9050", "http://[::1]:3128".</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00217"></a><span class="lineno"> 217</span> {</div>
|
|
<div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  <span class="comment">// NOLINTNEXTLINE(cppcoreguidelines-pro-type-vararg)</span></div>
|
|
<div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  CURLcode code{curl_easy_setopt(_connection, CURLOPT_PROXY, proxy.data())};</div>
|
|
<div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  <span class="keywordflow">if</span> (code != CURLE_OK)</div>
|
|
<div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  {</div>
|
|
<div class="line"><a name="l00222"></a><span class="lineno"> 222</span>  <span class="keywordflow">throw</span> CURLException{code, <span class="stringliteral">"Failed to set proxy"</span>, _curl_buffer_error};</div>
|
|
<div class="line"><a name="l00223"></a><span class="lineno"> 223</span>  }</div>
|
|
<div class="line"><a name="l00224"></a><span class="lineno"> 224</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="a0059ecb78b53c4b3c941b19f8dc897f7"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#a0059ecb78b53c4b3c941b19f8dc897f7">◆ </a></span>setup_connection_properties()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">void mastodonpp::CURLWrapper::setup_connection_properties </td>
|
|
<td>(</td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>proxy</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>access_token</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>cainfo</em>, </td>
|
|
</tr>
|
|
<tr>
|
|
<td class="paramkey"></td>
|
|
<td></td>
|
|
<td class="paramtype">string_view </td>
|
|
<td class="paramname"><em>useragent</em> </td>
|
|
</tr>
|
|
<tr>
|
|
<td></td>
|
|
<td>)</td>
|
|
<td></td><td></td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Set some properties of the connection. </p>
|
|
<p>Meant for internal use. See <a class="el" href="classmastodonpp_1_1Instance.html#aa486bc453907439e33f8402f270ef384" title="Set the properties of the connection of the calling class up.">Instance::copy_connection_properties()</a>.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.3.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00194"></a><span class="lineno"> 194</span> {</div>
|
|
<div class="line"><a name="l00195"></a><span class="lineno"> 195</span>  <span class="keywordflow">if</span> (!proxy.empty())</div>
|
|
<div class="line"><a name="l00196"></a><span class="lineno"> 196</span>  {</div>
|
|
<div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a1564a42794ef7a9d170b725063ef504d">set_proxy</a>(proxy);</div>
|
|
<div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  }</div>
|
|
<div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  </div>
|
|
<div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  <span class="keywordflow">if</span> (!access_token.empty())</div>
|
|
<div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  {</div>
|
|
<div class="line"><a name="l00202"></a><span class="lineno"> 202</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#a7a229cf9eae6bd03adfc2fdfdff62d88">set_access_token</a>(access_token);</div>
|
|
<div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  }</div>
|
|
<div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  </div>
|
|
<div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  <span class="keywordflow">if</span> (!cainfo.empty())</div>
|
|
<div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  {</div>
|
|
<div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  <a class="code" href="classmastodonpp_1_1CURLWrapper.html#af3f2bd4dea7c289d590fe19889360444">set_cainfo</a>(cainfo);</div>
|
|
<div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  }</div>
|
|
<div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  </div>
|
|
<div class="line"><a name="l00210"></a><span class="lineno"> 210</span>  <span class="keywordflow">if</span> (!useragent.empty())</div>
|
|
<div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  {</div>
|
|
<div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  set_useragent(useragent);</div>
|
|
<div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  }</div>
|
|
<div class="line"><a name="l00214"></a><span class="lineno"> 214</span> }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<a id="aed6d09b5c32d71276a851ddf321b5891"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aed6d09b5c32d71276a851ddf321b5891">◆ </a></span>unescape_url()</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">string mastodonpp::CURLWrapper::unescape_url </td>
|
|
<td>(</td>
|
|
<td class="paramtype">const string_view </td>
|
|
<td class="paramname"><em>url</em></td><td>)</td>
|
|
<td> const</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>URL decodes the given string . </p>
|
|
<p>For more information consult <a href="https://curl.haxx.se/libcurl/c/curl_easy_unescape.html">curl_easy_unescape(3)</a>.</p>
|
|
<dl class="params"><dt>Parameters</dt><dd>
|
|
<table class="params">
|
|
<tr><td class="paramname">url</td><td>String to unescape.</td></tr>
|
|
</table>
|
|
</dd>
|
|
</dl>
|
|
<dl class="section return"><dt>Returns</dt><dd>The unescaped string or {} if it failed.</dd></dl>
|
|
<dl class="section since"><dt>Since</dt><dd>0.3.0 </dd></dl>
|
|
<div class="fragment"><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  {</div>
|
|
<div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="keywordtype">char</span> *cbuf{curl_easy_unescape(_connection, url.data(),</div>
|
|
<div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  static_cast<int>(url.size()), <span class="keyword">nullptr</span>)};</div>
|
|
<div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keywordtype">string</span> sbuf{cbuf};</div>
|
|
<div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  curl_free(cbuf);</div>
|
|
<div class="line"><a name="l00151"></a><span class="lineno"> 151</span>  <span class="keywordflow">return</span> sbuf;</div>
|
|
<div class="line"><a name="l00152"></a><span class="lineno"> 152</span>  }</div>
|
|
</div><!-- fragment -->
|
|
</div>
|
|
</div>
|
|
<h2 class="groupheader">Member Data Documentation</h2>
|
|
<a id="aeb3171d955832b8062dc02b4ac67d195"></a>
|
|
<h2 class="memtitle"><span class="permalink"><a href="#aeb3171d955832b8062dc02b4ac67d195">◆ </a></span>buffer_mutex</h2>
|
|
|
|
<div class="memitem">
|
|
<div class="memproto">
|
|
<table class="mlabels">
|
|
<tr>
|
|
<td class="mlabels-left">
|
|
<table class="memname">
|
|
<tr>
|
|
<td class="memname">mutex mastodonpp::CURLWrapper::buffer_mutex</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
<td class="mlabels-right">
|
|
<span class="mlabels"><span class="mlabel">protected</span></span> </td>
|
|
</tr>
|
|
</table>
|
|
</div><div class="memdoc">
|
|
|
|
<p>Mutex for <a class="el" href="classmastodonpp_1_1CURLWrapper.html#a04b3919cfb38716c5a032337e442db95" title="Returns a reference to the buffer libcurl writes into.">get_buffer</a> a.k.a. _curl_buffer_body. </p>
|
|
<p>This mutex is locked before anything is read or written from/to _curl_buffer_body.</p>
|
|
<dl class="section since"><dt>Since</dt><dd>0.1.0 </dd></dl>
|
|
|
|
</div>
|
|
</div>
|
|
<hr/>The documentation for this class was generated from the following files:<ul>
|
|
<li>include/<a class="el" href="curl__wrapper_8hpp_source.html">curl_wrapper.hpp</a></li>
|
|
<li>src/curl_wrapper.cpp</li>
|
|
</ul>
|
|
</div><!-- contents -->
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a7a229cf9eae6bd03adfc2fdfdff62d88"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a7a229cf9eae6bd03adfc2fdfdff62d88">mastodonpp::CURLWrapper::set_access_token</a></div><div class="ttdeci">void set_access_token(const string_view access_token)</div><div class="ttdoc">Set OAuth 2.0 Bearer Access Token.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:226</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_a1564a42794ef7a9d170b725063ef504d"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#a1564a42794ef7a9d170b725063ef504d">mastodonpp::CURLWrapper::set_proxy</a></div><div class="ttdeci">void set_proxy(string_view proxy)</div><div class="ttdoc">Set the proxy to use.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:216</div></div>
|
|
<div class="ttc" id="aclassmastodonpp_1_1CURLWrapper_html_af3f2bd4dea7c289d590fe19889360444"><div class="ttname"><a href="classmastodonpp_1_1CURLWrapper.html#af3f2bd4dea7c289d590fe19889360444">mastodonpp::CURLWrapper::set_cainfo</a></div><div class="ttdeci">void set_cainfo(string_view path)</div><div class="ttdoc">Set path to Certificate Authority (CA) bundle.</div><div class="ttdef"><b>Definition:</b> curl_wrapper.cpp:252</div></div>
|
|
<!-- start footer part -->
|
|
<hr class="footer"/><address class="footer"><small>
|
|
Generated by  <a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
|
</a> 1.8.16
|
|
</small></address>
|
|
</body>
|
|
</html>
|