curly/requester.hpp

33 lines
699 B
C++
Raw Normal View History

//
// 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();
// 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_