diff options
author | Andy Schwerin <schwerin@10gen.com> | 2013-12-05 15:56:14 -0500 |
---|---|---|
committer | Andy Schwerin <schwerin@10gen.com> | 2013-12-10 17:54:04 -0500 |
commit | 2f61f0248d0d41078d3c0b94092493361557ec29 (patch) | |
tree | 34697f1a945ae74dcab7424d5729af43b6b0661b /src/mongo/client/examples | |
parent | 82e8115bacf418f3fe8af50e04b7d6ca218d87f1 (diff) | |
download | mongo-2f61f0248d0d41078d3c0b94092493361557ec29.tar.gz |
SERVER-3364 Label enough of the client api with MONGO_CLIENT_API to build httpClientTest.
Diffstat (limited to 'src/mongo/client/examples')
-rw-r--r-- | src/mongo/client/examples/httpClientTest.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/mongo/client/examples/httpClientTest.cpp b/src/mongo/client/examples/httpClientTest.cpp index 973b29bf9f6..0608f78931a 100644 --- a/src/mongo/client/examples/httpClientTest.cpp +++ b/src/mongo/client/examples/httpClientTest.cpp @@ -17,7 +17,6 @@ #include <iostream> -#include "mongo/base/init.h" #include "mongo/client/dbclient.h" #include "mongo/util/net/httpclient.h" @@ -25,10 +24,10 @@ # define verify(x) MONGO_verify(x) #endif -using namespace mongo; +void play( std::string url ) { + using mongo::HttpClient; -void play( string url ) { - cout << "[" << url << "]" << endl; + std::cout << "[" << url << "]" << std::endl; HttpClient c; HttpClient::Result r; @@ -37,32 +36,37 @@ void play( string url ) { HttpClient::Headers h = r.getHeaders(); verify( h["Content-Type"].find( "text/html" ) == 0 ); - cout << "\tHeaders" << endl; + std::cout << "\tHeaders" << std::endl; for ( HttpClient::Headers::iterator i = h.begin() ; i != h.end(); ++i ) { - cout << "\t\t" << i->first << "\t" << i->second << endl; + std::cout << "\t\t" << i->first << "\t" << i->second << std::endl; } - + } int main( int argc, const char **argv, char **envp) { #ifdef MONGO_SSL - sslGlobalParams.sslMode.store(SSLGlobalParams::SSLMode_requireSSL); - runGlobalInitializersOrDie(argc, argv, envp); + mongo::sslGlobalParams.sslMode.store(mongo::SSLGlobalParams::SSLMode_requireSSL); #endif + mongo::Status status = mongo::client::initialize(); + if (!status.isOK()) { + std::cout << "Failed to initialize mongodb client. " << status << std::endl; + return EXIT_FAILURE; + } + int port = 27017; if ( argc != 1 ) { if ( argc != 3 ) { - cout << "need to pass port as second param" << endl; + std::cout << "need to pass port as second param" << std::endl; return EXIT_FAILURE; } port = atoi( argv[ 2 ] ); } port += 1000; - play( str::stream() << "http://localhost:" << port << "/" ); - + play( mongo::str::stream() << "http://localhost:" << port << "/" ); + #ifdef MONGO_SSL play( "https://www.mongodb.com/" ); #endif |