39 lines
933 B
C++
39 lines
933 B
C++
//
|
|
// 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>
|
|
#include <memory>
|
|
#include <curl/curl.h>
|
|
|
|
class requester {
|
|
public:
|
|
// callback for data receiving
|
|
static size_t write_data(char* buf, size_t sz, size_t nmemb, void* user_data);
|
|
|
|
// this class is a RAII class for a curl handle
|
|
requester();
|
|
~requester();
|
|
|
|
// forbid copying and moving
|
|
requester(const requester&) = delete;
|
|
requester& operator=(const requester&) = delete;
|
|
requester(requester&&) = delete;
|
|
requester& operator=(requester&&) = delete;
|
|
|
|
// perform a http get request
|
|
std::string get(const std::string& url);
|
|
|
|
private:
|
|
std::unique_ptr<CURL, void(*)(CURL*)> _h {nullptr, curl_easy_cleanup};
|
|
};
|
|
|
|
#endif // _requester_H_
|