From a6916f6179a1815b2c3878ae9db7bd199816c7f2 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Thu, 8 Feb 2018 00:56:04 +0000 Subject: [PATCH] Read from stdin when source is - --- src/html_pool.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/html_pool.cpp b/src/html_pool.cpp index add1ec2..756222a 100644 --- a/src/html_pool.cpp +++ b/src/html_pool.cpp @@ -18,9 +18,11 @@ #include "html_pool.hpp" #include "htmlretrieve.hpp" +#include "read_all.hpp" #include #include #include +#include namespace duck { HtmlPool::HtmlPool (std::string&& agent_name) : @@ -29,9 +31,17 @@ namespace duck { } auto HtmlPool::OnResourceLoad (ResourceObjectParameterType parRes) -> ResourceType* { - auto html = std::make_unique( - fetch_html(parRes, m_agent, false, false) - ); + std::unique_ptr html; + + if (parRes == "-") { + html = std::make_unique(read_all(std::cin)); + } + else { + html = std::make_unique( + fetch_html(parRes, m_agent, false, false) + ); + } + *html = duck::clean_html(std::move(*html)); return html.release(); }