aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/utils/http_util/http_util.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/utils/http_util/http_util.cpp b/src/lib/utils/http_util/http_util.cpp
index 970b90238..f0412a57e 100644
--- a/src/lib/utils/http_util/http_util.cpp
+++ b/src/lib/utils/http_util/http_util.cpp
@@ -26,6 +26,8 @@
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
+#else
+ #warning "No network support enabled in http_util"
#endif
namespace Botan {
@@ -101,7 +103,7 @@ std::string http_transact(const std::string& hostname,
ssize_t sent = ::write(fd, &message[sent_so_far], left);
if(sent < 0)
- throw HTTP_Error("HTTP server hung up on us");
+ throw HTTP_Error("write to HTTP server failed, error '" + std::string(::strerror(errno)) + "'");
else
sent_so_far += static_cast<size_t>(sent);
}
@@ -113,7 +115,7 @@ std::string http_transact(const std::string& hostname,
ssize_t got = ::read(fd, buf.data(), buf.size());
if(got < 0)
- throw HTTP_Error("HTTP server hung up on us");
+ throw HTTP_Error("read from HTTP server failed, error '" + std::string(::strerror(errno)) + "'");
else if(got > 0)
oss.write(buf.data(), static_cast<std::streamsize>(got));
else
@@ -122,8 +124,7 @@ std::string http_transact(const std::string& hostname,
return oss.str();
#else
- throw HTTP_Error("Cannot connect to " + hostname +
- ": network code disabled in build");
+ throw HTTP_Error("Cannot connect to " + hostname + ": network code disabled in build");
#endif
}
@@ -167,9 +168,12 @@ Response http_sync(http_exch_fn http_transact,
const std::vector<byte>& body,
size_t allowable_redirects)
{
+ if(url.empty())
+ throw HTTP_Error("URL empty");
+
const auto protocol_host_sep = url.find("://");
if(protocol_host_sep == std::string::npos)
- throw HTTP_Error("Invalid URL " + url);
+ throw HTTP_Error("Invalid URL '" + url + "'");
const auto host_loc_sep = url.find('/', protocol_host_sep + 3);