Read from stdin when source is -

This commit is contained in:
King_DuckZ 2018-02-08 00:56:04 +00:00
parent 1d750ad2f9
commit a6916f6179

View file

@ -18,9 +18,11 @@
#include "html_pool.hpp" #include "html_pool.hpp"
#include "htmlretrieve.hpp" #include "htmlretrieve.hpp"
#include "read_all.hpp"
#include <string> #include <string>
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <iostream>
namespace duck { namespace duck {
HtmlPool::HtmlPool (std::string&& agent_name) : HtmlPool::HtmlPool (std::string&& agent_name) :
@ -29,9 +31,17 @@ namespace duck {
} }
auto HtmlPool::OnResourceLoad (ResourceObjectParameterType parRes) -> ResourceType* { auto HtmlPool::OnResourceLoad (ResourceObjectParameterType parRes) -> ResourceType* {
auto html = std::make_unique<std::string>( std::unique_ptr<std::string> html;
if (parRes == "-") {
html = std::make_unique<std::string>(read_all(std::cin));
}
else {
html = std::make_unique<std::string>(
fetch_html(parRes, m_agent, false, false) fetch_html(parRes, m_agent, false, false)
); );
}
*html = duck::clean_html(std::move(*html)); *html = duck::clean_html(std::move(*html));
return html.release(); return html.release();
} }