From f7e3c10eca9b77880f99cd2012553b4eef932e57 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 12 Dec 2013 11:33:41 -0800 Subject: Cleanup in Utils, fix for HttpClient on Linux. --- node/HttpClient.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'node/HttpClient.cpp') diff --git a/node/HttpClient.cpp b/node/HttpClient.cpp index 15c01c44..d4e76018 100644 --- a/node/HttpClient.cpp +++ b/node/HttpClient.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #endif namespace ZeroTier { @@ -68,7 +69,6 @@ const std::map HttpClient::NO_HEADERS; // Paths where "curl" may be found on the system #define NUM_CURL_PATHS 5 static const char *CURL_PATHS[NUM_CURL_PATHS] = { "/usr/bin/curl","/bin/curl","/usr/local/bin/curl","/usr/sbin/curl","/sbin/curl" }; -static const std::string CURL_IN_HOME(ZT_DEFAULTS.defaultHomePath + "/curl"); // Maximum message length #define CURL_MAX_MESSAGE_LENGTH (1024 * 1024 * 64) @@ -102,10 +102,6 @@ public: break; } } - if (!curlPath.length()) { - if (Utils::fileExists(CURL_IN_HOME.c_str())) - curlPath = CURL_IN_HOME; - } if (!curlPath.length()) { _handler(_arg,-1,_url,false,"unable to locate 'curl' binary in /usr/bin, /bin, /usr/local/bin, /usr/sbin, or /sbin"); delete this; @@ -201,6 +197,19 @@ public: } if (waitpid(pid,&exitCode,WNOHANG) > 0) { + for(;;) { + // Drain output... + int n = (int)::read(curlStdout[0],buf,sizeof(buf)); + if (n <= 0) + break; + else { + _body.append(buf,n); + if (_body.length() > CURL_MAX_MESSAGE_LENGTH) { + tooLong = true; + break; + } + } + } pid = 0; break; } -- cgit v1.2.3