diff options
author | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
---|---|---|
committer | Antonin Kral <a.kral@bobek.cz> | 2011-09-14 17:08:06 +0200 |
commit | 5d342a758c6095b4d30aba0750b54f13b8916f51 (patch) | |
tree | 762e9aa84781f5e3b96db2c02d356c29cf0217c0 /client/examples/httpClientTest.cpp | |
parent | cbe2d992e9cd1ea66af9fa91df006106775d3073 (diff) | |
download | mongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz |
Imported Upstream version 2.0.0
Diffstat (limited to 'client/examples/httpClientTest.cpp')
-rw-r--r-- | client/examples/httpClientTest.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/client/examples/httpClientTest.cpp b/client/examples/httpClientTest.cpp index 4fa5fd8..4055d44 100644 --- a/client/examples/httpClientTest.cpp +++ b/client/examples/httpClientTest.cpp @@ -18,10 +18,27 @@ #include <iostream> #include "client/dbclient.h" -#include "util/httpclient.h" +#include "util/net/httpclient.h" using namespace mongo; +void play( string url ) { + cout << "[" << url << "]" << endl; + + HttpClient c; + HttpClient::Result r; + MONGO_assert( c.get( url , &r ) == 200 ); + + HttpClient::Headers h = r.getHeaders(); + MONGO_assert( h["Content-Type"].find( "text/html" ) == 0 ); + + cout << "\tHeaders" << endl; + for ( HttpClient::Headers::iterator i = h.begin() ; i != h.end(); ++i ) { + cout << "\t\t" << i->first << "\t" << i->second << endl; + } + +} + int main( int argc, const char **argv ) { int port = 27017; @@ -32,12 +49,10 @@ int main( int argc, const char **argv ) { } port += 1000; - stringstream ss; - ss << "http://localhost:" << port << "/"; - string url = ss.str(); - - cout << "[" << url << "]" << endl; - - HttpClient c; - MONGO_assert( c.get( url ) == 200 ); + play( str::stream() << "http://localhost:" << port << "/" ); + +#ifdef MONGO_SSL + play( "https://www.10gen.com/" ); +#endif + } |