diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-12-06 16:00:12 -0800 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2013-12-06 16:00:12 -0800 |
| commit | 518410b7e0f8b88ee8822e4449e91f7c52d1022a (patch) | |
| tree | 323d6f71c30170c3689ca48cd61422171af38806 /selftest.cpp | |
| parent | 0a0ed893c3878c82070392bf953ecb16d50734d9 (diff) | |
| download | infinitytier-518410b7e0f8b88ee8822e4449e91f7c52d1022a.tar.gz infinitytier-518410b7e0f8b88ee8822e4449e91f7c52d1022a.zip | |
HTTP client works!
Diffstat (limited to 'selftest.cpp')
| -rw-r--r-- | selftest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/selftest.cpp b/selftest.cpp index ba362bd3..50a14e0f 100644 --- a/selftest.cpp +++ b/selftest.cpp @@ -52,6 +52,7 @@ #include "node/C25519.hpp" #include "node/Poly1305.hpp" #include "node/CertificateOfMembership.hpp" +#include "node/HttpClient.hpp" #ifdef __WINDOWS__ #include <tchar.h> @@ -63,6 +64,40 @@ using namespace ZeroTier; static unsigned char fuzzbuf[1048576]; +static Condition webDoneCondition; +static void testHttpHandler(void *arg,int code,const std::string &url,bool onDisk,const std::string &body) +{ + if (code == 200) + std::cout << "got " << body.length() << " bytes, response code " << code << std::endl; + else std::cout << "ERROR " << code << ": " << body << std::endl; + webDoneCondition.signal(); +} + +static int testHttp() +{ + std::cout << "[http] fetching http://download.zerotier.com/dev/1k ... "; std::cout.flush(); + HttpClient::GET("http://download.zerotier.com/dev/1k",HttpClient::NO_HEADERS,30,&testHttpHandler,(void *)0); + webDoneCondition.wait(); + + std::cout << "[http] fetching http://download.zerotier.com/dev/2k ... "; std::cout.flush(); + HttpClient::GET("http://download.zerotier.com/dev/2k",HttpClient::NO_HEADERS,30,&testHttpHandler,(void *)0); + webDoneCondition.wait(); + + std::cout << "[http] fetching http://download.zerotier.com/dev/4k ... "; std::cout.flush(); + HttpClient::GET("http://download.zerotier.com/dev/4k",HttpClient::NO_HEADERS,30,&testHttpHandler,(void *)0); + webDoneCondition.wait(); + + std::cout << "[http] fetching http://download.zerotier.com/dev/8k ... "; std::cout.flush(); + HttpClient::GET("http://download.zerotier.com/dev/8k",HttpClient::NO_HEADERS,30,&testHttpHandler,(void *)0); + webDoneCondition.wait(); + + std::cout << "[http] fetching http://download.zerotier.com/dev/NOEXIST ... "; std::cout.flush(); + HttpClient::GET("http://download.zerotier.com/dev/NOEXIST",HttpClient::NO_HEADERS,30,&testHttpHandler,(void *)0); + webDoneCondition.wait(); + + return 0; +} + static int testCrypto() { unsigned char buf1[16384]; @@ -562,6 +597,7 @@ int main(int argc,char **argv) srand((unsigned int)time(0)); + r |= testHttp(); r |= testCrypto(); r |= testPacket(); r |= testOther(); |
