Files
spark/src/lib/utils/HTTPStream.h
T

38 lines
841 B
C++

#pragma once
#include "bts_export.h"
#include "lib/utils/bts_no_copy.h"
#include "lib/utils/windows_wrapper.h"
#include <boost/asio.hpp>
#include <map>
namespace bts {
namespace utils {
class BTS_EXPORT HTTPStream : public boost::asio::ip::tcp::iostream {
public:
HTTPStream(
const std::string &host,
const std::string &path,
const std::string &verb = "GET");
~HTTPStream();
static const int OK = 200;
int response() { return _response; }
const std::map<std::string, std::string> &headers() const {
return _headers;
}
private:
int _response;
std::map<std::string, std::string> _headers;
BTS_NO_COPY(HTTPStream);
};
bool download_file_if_newer(
const std::string &host,
const std::string &path,
const std::string &destination);
} // namespace utils
} // namespace bts