2020-09-02 09:53:22 +02:00
|
|
|
//
|
|
|
|
// requester.hpp
|
|
|
|
// curly
|
|
|
|
//
|
|
|
|
// Created by Bob Polis at 2020-09-01
|
|
|
|
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef _requester_H_
|
|
|
|
#define _requester_H_
|
|
|
|
|
|
|
|
#include <string>
|
2020-09-12 19:34:32 +02:00
|
|
|
#include <memory>
|
2020-09-02 09:53:22 +02:00
|
|
|
#include <curl/curl.h>
|
|
|
|
|
|
|
|
class requester {
|
|
|
|
public:
|
2020-09-02 10:59:31 +02:00
|
|
|
// callback for data receiving
|
2020-09-02 09:53:22 +02:00
|
|
|
static size_t write_data(char* buf, size_t sz, size_t nmemb, void* user_data);
|
|
|
|
|
2020-09-02 10:59:31 +02:00
|
|
|
// this class is a RAII class for a curl handle
|
2020-09-02 09:53:22 +02:00
|
|
|
requester();
|
2020-09-02 10:59:31 +02:00
|
|
|
|
2020-09-12 19:34:32 +02:00
|
|
|
// perform a http get request
|
2020-09-02 09:53:22 +02:00
|
|
|
std::string get(const std::string& url);
|
|
|
|
|
|
|
|
private:
|
2020-09-12 19:34:32 +02:00
|
|
|
std::unique_ptr<CURL, void(*)(CURL*)> _h {nullptr, curl_easy_cleanup};
|
2020-09-02 09:53:22 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _requester_H_
|