From 39b2a3d6df3df9c2e0f27f3a003e719abc01334a Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Fri, 19 Mar 2021 11:35:25 -0700 Subject: [PATCH] ws curl -O mingw compile fix + detect when we cannot extract a filename from the url to save file to disk with -O option --- ws/ws.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ws/ws.cpp b/ws/ws.cpp index 57c846c5..350901d1 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -1427,10 +1427,16 @@ namespace ix filename = output; } - spdlog::info("Writing to disk: {}", filename); - std::ofstream out(filename); - out.write((char*) &response->body.front(), response->body.size()); - out.close(); + if (filename.empty()) + { + spdlog::error("Cannot save content to disk: No output file supplied, and not filename could be extracted from the url {}", url); + } + else + { + spdlog::info("Writing to disk: {}", filename); + std::ofstream out(filename); + out << response->body; + } } else {