orotool/src/nap/quick_rest.cpp

38 lines
1.2 KiB
C++
Raw Normal View History

2020-08-29 14:28:47 +01:00
/* Copyright 2020, Michele Santullo
* This file is part of orotool.
*
* Orotool is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Orotool is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Orotool. If not, see <http://www.gnu.org/licenses/>.
*/
#include "quick_rest.hpp"
#include "private/page_fetch.hpp"
namespace nap {
void QuickRest::add_headers (std::initializer_list<HeaderPairView> headers) {
for (const auto& entry : headers) {
using std::string;
m_header.emplace_back(string(entry.first), string(entry.second));
}
}
void QuickRest::set_user_agent (std::string&& name) {
m_user_agent = std::move(name);
}
HttpResponse QuickRest::fetch (std::string_view url) {
return page_fetch(std::string(url), m_user_agent, m_header);
2020-08-29 14:28:47 +01:00
}
} //namespace nap