Update to newer rexylib
This commit is contained in:
parent
4ea29e5789
commit
392eaa4678
@ -79,18 +79,18 @@ namespace rcw{
|
|||||||
response perform(void);
|
response perform(void);
|
||||||
|
|
||||||
string escape(const char* data, int len = 0);
|
string escape(const char* data, int len = 0);
|
||||||
string escape(const rexy::string_base<char>& data);
|
string escape(rexy::string_view data);
|
||||||
std::string escape_to_std(const char* data, int len = 0);
|
std::string escape_to_std(const char* data, int len = 0);
|
||||||
std::string escape_to_std(const rexy::string_base<char>& data);
|
std::string escape_to_std(rexy::string_view data);
|
||||||
char* escape_to_cstr(const char* data, int* outlen, int len = 0);
|
char* escape_to_cstr(const char* data, int* outlen, int len = 0);
|
||||||
char* escape_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
char* escape_to_cstr(rexy::string_view data, int* outlen);
|
||||||
|
|
||||||
std::string unescape_to_std(const char* data, int len = 0);
|
std::string unescape_to_std(const char* data, int len = 0);
|
||||||
std::string unescape_to_std(const rexy::string_base<char>& data);
|
std::string unescape_to_std(rexy::string_view data);
|
||||||
string unescape(const char* data, int len = 0);
|
string unescape(const char* data, int len = 0);
|
||||||
string unescape(const rexy::string_base<char>& data);
|
string unescape(rexy::string_view data);
|
||||||
char* unescape_to_cstr(const char* data, int* outlen, int len = 0);
|
char* unescape_to_cstr(const char* data, int* outlen, int len = 0);
|
||||||
char* unescape_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
char* unescape_to_cstr(rexy::string_view data, int* outlen);
|
||||||
|
|
||||||
long get_last_status(void)const;
|
long get_last_status(void)const;
|
||||||
CURL* get(void);
|
CURL* get(void);
|
||||||
|
|||||||
@ -35,7 +35,7 @@ namespace rcw{
|
|||||||
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
||||||
return std::async([=]() -> response
|
return std::async([=]() -> response
|
||||||
{
|
{
|
||||||
return get(rcw::url(*url_copy), *hlist);
|
return get(rcw::url(url_copy->data()), *hlist);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ namespace rcw{
|
|||||||
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
||||||
return std::async([=]() -> response
|
return std::async([=]() -> response
|
||||||
{
|
{
|
||||||
return post(rcw::url(*url_copy), rcw::body(*body_copy), *hlist);
|
return post(rcw::url(url_copy->data()), rcw::body(body_copy->data()), *hlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ namespace rcw{
|
|||||||
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
||||||
return std::async([=]() -> response
|
return std::async([=]() -> response
|
||||||
{
|
{
|
||||||
return put(rcw::url(*url_copy), rcw::body(*body_copy), *hlist);
|
return put(rcw::url(url_copy->data()), rcw::body(body_copy->data()), *hlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace rcw{
|
|||||||
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
||||||
return std::async([=]() -> response
|
return std::async([=]() -> response
|
||||||
{
|
{
|
||||||
return del(rcw::url(*url_copy), *hlist);
|
return del(rcw::url(url_copy->data()), *hlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
std::future<response> async_del(const url& u, const body& b, std::initializer_list<header> headers){
|
std::future<response> async_del(const url& u, const body& b, std::initializer_list<header> headers){
|
||||||
@ -98,7 +98,7 @@ namespace rcw{
|
|||||||
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
std::shared_ptr<curl_header_list> hlist(new curl_header_list(headers));
|
||||||
return std::async([=]() -> response
|
return std::async([=]() -> response
|
||||||
{
|
{
|
||||||
return del(rcw::url(*url_copy), rcw::body(*body_copy), *hlist);
|
return del(rcw::url(url_copy->data()), rcw::body(body_copy->data()), *hlist);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -179,28 +179,28 @@ namespace rcw{
|
|||||||
char* tmp = escape_to_cstr(data, &len, len);
|
char* tmp = escape_to_cstr(data, &len, len);
|
||||||
return string(rexy::steal(tmp), len, len);
|
return string(rexy::steal(tmp), len, len);
|
||||||
}
|
}
|
||||||
string curl_easy_handle::escape(const rexy::string_base<char>& data){
|
string curl_easy_handle::escape(rexy::string_view data){
|
||||||
return escape(data.get(), data.length());
|
return escape(data.data(), data.length());
|
||||||
}
|
}
|
||||||
std::string curl_easy_handle::escape_to_std(const rexy::string_base<char>& data){
|
std::string curl_easy_handle::escape_to_std(rexy::string_view data){
|
||||||
return escape_to_std(data.get(), data.length());
|
return escape_to_std(data.data(), data.length());
|
||||||
}
|
}
|
||||||
char* curl_easy_handle::escape_to_cstr(const rexy::string_base<char>& data, int* outlen){
|
char* curl_easy_handle::escape_to_cstr(rexy::string_view data, int* outlen){
|
||||||
return escape_to_cstr(data.get(), outlen, data.length());
|
return escape_to_cstr(data.data(), outlen, data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
string curl_easy_handle::unescape(const char* data, int len){
|
string curl_easy_handle::unescape(const char* data, int len){
|
||||||
char* tmp = unescape_to_cstr(data, &len, len);
|
char* tmp = unescape_to_cstr(data, &len, len);
|
||||||
return string(rexy::steal(tmp), len, len);
|
return string(rexy::steal(tmp), len, len);
|
||||||
}
|
}
|
||||||
string curl_easy_handle::unescape(const rexy::string_base<char>& data){
|
string curl_easy_handle::unescape(rexy::string_view data){
|
||||||
return unescape(data.get(), data.length());
|
return unescape(data.data(), data.length());
|
||||||
}
|
}
|
||||||
std::string curl_easy_handle::unescape_to_std(const rexy::string_base<char>& data){
|
std::string curl_easy_handle::unescape_to_std(rexy::string_view data){
|
||||||
return unescape_to_std(data.get(), data.length());
|
return unescape_to_std(data.data(), data.length());
|
||||||
}
|
}
|
||||||
char* curl_easy_handle::unescape_to_cstr(const rexy::string_base<char>& data, int* outlen){
|
char* curl_easy_handle::unescape_to_cstr(rexy::string_view data, int* outlen){
|
||||||
return escape_to_cstr(data.get(), outlen, data.length());
|
return escape_to_cstr(data.data(), outlen, data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
src/sync.cpp
16
src/sync.cpp
@ -35,7 +35,7 @@ namespace rcw{
|
|||||||
c.set_header(headers);
|
c.set_header(headers);
|
||||||
c.set_read_data(nullptr);
|
c.set_read_data(nullptr);
|
||||||
c.set_write_data(cback);
|
c.set_write_data(cback);
|
||||||
c.set_url(u.data);
|
c.set_url(u.data.data());
|
||||||
return c.perform();
|
return c.perform();
|
||||||
}
|
}
|
||||||
response post_impl(curl_easy_handle& c, curl_cback_invoker* read_cback, curl_cback_invoker* write_cback, const url& u, const curl_header_list& headers){
|
response post_impl(curl_easy_handle& c, curl_cback_invoker* read_cback, curl_cback_invoker* write_cback, const url& u, const curl_header_list& headers){
|
||||||
@ -44,7 +44,7 @@ namespace rcw{
|
|||||||
c.set_read_fun(curl_read_callback);
|
c.set_read_fun(curl_read_callback);
|
||||||
c.set_read_data(read_cback);
|
c.set_read_data(read_cback);
|
||||||
c.set_write_data(write_cback);
|
c.set_write_data(write_cback);
|
||||||
c.set_url(u.data);
|
c.set_url(u.data.data());
|
||||||
c.set_header(headers);
|
c.set_header(headers);
|
||||||
return c.perform();
|
return c.perform();
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ namespace rcw{
|
|||||||
c.set_read_fun(curl_read_callback);
|
c.set_read_fun(curl_read_callback);
|
||||||
c.set_read_data(read_cback);
|
c.set_read_data(read_cback);
|
||||||
c.set_write_data(write_cback);
|
c.set_write_data(write_cback);
|
||||||
c.set_url(u.data);
|
c.set_url(u.data.data());
|
||||||
c.set_header(headers);
|
c.set_header(headers);
|
||||||
return c.perform();
|
return c.perform();
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ namespace rcw{
|
|||||||
c.set_read_fun(curl_read_callback);
|
c.set_read_fun(curl_read_callback);
|
||||||
c.set_write_data(write_cback);
|
c.set_write_data(write_cback);
|
||||||
c.set_read_data(read_cback);
|
c.set_read_data(read_cback);
|
||||||
c.set_url(u.data);
|
c.set_url(u.data.data());
|
||||||
c.set_header(headers);
|
c.set_header(headers);
|
||||||
return c.perform();
|
return c.perform();
|
||||||
}
|
}
|
||||||
@ -79,7 +79,7 @@ namespace rcw{
|
|||||||
c.set_write_fun(curl_write_callback);
|
c.set_write_fun(curl_write_callback);
|
||||||
c.set_write_data(write_cback);
|
c.set_write_data(write_cback);
|
||||||
c.set_read_data(nullptr);
|
c.set_read_data(nullptr);
|
||||||
c.set_url(u.data);
|
c.set_url(u.data.data());
|
||||||
c.set_header(headers);
|
c.set_header(headers);
|
||||||
return c.perform();
|
return c.perform();
|
||||||
}
|
}
|
||||||
@ -130,7 +130,7 @@ namespace rcw{
|
|||||||
return post(c, u, b, curl_header_list(headers));
|
return post(c, u, b, curl_header_list(headers));
|
||||||
}
|
}
|
||||||
response post(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
response post(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
||||||
default_curl_read_callback rcb{b.data.get(), b.data.length()};
|
default_curl_read_callback rcb{b.data.data(), b.data.length()};
|
||||||
default_curl_write_callback wcb{};
|
default_curl_write_callback wcb{};
|
||||||
response retval = post(c, rcb, wcb, u, headers);
|
response retval = post(c, rcb, wcb, u, headers);
|
||||||
retval.text = std::move(wcb.data);
|
retval.text = std::move(wcb.data);
|
||||||
@ -164,7 +164,7 @@ namespace rcw{
|
|||||||
return put(c, u, b, curl_header_list(headers));
|
return put(c, u, b, curl_header_list(headers));
|
||||||
}
|
}
|
||||||
response put(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
response put(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
||||||
default_curl_read_callback rcb{b.data.get(), b.data.length()};
|
default_curl_read_callback rcb{b.data.data(), b.data.length()};
|
||||||
default_curl_write_callback wcb{};
|
default_curl_write_callback wcb{};
|
||||||
response retval = put(c, rcb, wcb, u, headers);
|
response retval = put(c, rcb, wcb, u, headers);
|
||||||
retval.text = std::move(wcb.data);
|
retval.text = std::move(wcb.data);
|
||||||
@ -200,7 +200,7 @@ namespace rcw{
|
|||||||
return del(c, u, b, curl_header_list(headers));
|
return del(c, u, b, curl_header_list(headers));
|
||||||
}
|
}
|
||||||
response del(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
response del(curl_easy_handle& c, const url& u, const body& b, const curl_header_list& headers){
|
||||||
default_curl_read_callback rcb{b.data.get(), b.data.length()};
|
default_curl_read_callback rcb{b.data.data(), b.data.length()};
|
||||||
default_curl_write_callback wcb{};
|
default_curl_write_callback wcb{};
|
||||||
response retval = del(c, rcb, wcb, u, headers);
|
response retval = del(c, rcb, wcb, u, headers);
|
||||||
retval.text = std::move(wcb.data);
|
retval.text = std::move(wcb.data);
|
||||||
|
|||||||
@ -9,7 +9,7 @@ void do_async_get(){
|
|||||||
rcw::response reply = f_reply.get();
|
rcw::response reply = f_reply.get();
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
void do_async_post(){
|
void do_async_post(){
|
||||||
PRINT_RUNNING_FUNC();
|
PRINT_RUNNING_FUNC();
|
||||||
@ -17,7 +17,7 @@ void do_async_post(){
|
|||||||
rcw::response reply = f_reply.get();
|
rcw::response reply = f_reply.get();
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
void do_async_put(){
|
void do_async_put(){
|
||||||
PRINT_RUNNING_FUNC();
|
PRINT_RUNNING_FUNC();
|
||||||
@ -25,7 +25,7 @@ void do_async_put(){
|
|||||||
rcw::response reply = f_reply.get();
|
rcw::response reply = f_reply.get();
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
void do_async_del(){
|
void do_async_del(){
|
||||||
PRINT_RUNNING_FUNC();
|
PRINT_RUNNING_FUNC();
|
||||||
@ -33,7 +33,7 @@ void do_async_del(){
|
|||||||
rcw::response reply = f_reply.get();
|
rcw::response reply = f_reply.get();
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|||||||
@ -8,7 +8,7 @@ void do_get(){
|
|||||||
rcw::response reply = rcw::get(rcw::url("https://httpbin.org/get"));
|
rcw::response reply = rcw::get(rcw::url("https://httpbin.org/get"));
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void do_post(){
|
void do_post(){
|
||||||
@ -16,21 +16,21 @@ void do_post(){
|
|||||||
rcw::response reply = rcw::post(rcw::url("https://httpbin.org/post"));
|
rcw::response reply = rcw::post(rcw::url("https://httpbin.org/post"));
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
void do_put(){
|
void do_put(){
|
||||||
PRINT_RUNNING_FUNC();
|
PRINT_RUNNING_FUNC();
|
||||||
rcw::response reply = rcw::put(rcw::url("https://httpbin.org/put"));
|
rcw::response reply = rcw::put(rcw::url("https://httpbin.org/put"));
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
void do_del(){
|
void do_del(){
|
||||||
PRINT_RUNNING_FUNC();
|
PRINT_RUNNING_FUNC();
|
||||||
rcw::response reply = rcw::del(rcw::url("https://httpbin.org/delete"));
|
rcw::response reply = rcw::del(rcw::url("https://httpbin.org/delete"));
|
||||||
printf("%ld\n", reply.status.get());
|
printf("%ld\n", reply.status.get());
|
||||||
if(reply.ok())
|
if(reply.ok())
|
||||||
printf("%s\n", reply.text.get());
|
printf("%s\n", reply.text.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user