summaryrefslogtreecommitdiff
path: root/client/examples/httpClientTest.cpp
diff options
context:
space:
mode:
authorAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
committerAntonin Kral <a.kral@bobek.cz>2011-09-14 17:08:06 +0200
commit5d342a758c6095b4d30aba0750b54f13b8916f51 (patch)
tree762e9aa84781f5e3b96db2c02d356c29cf0217c0 /client/examples/httpClientTest.cpp
parentcbe2d992e9cd1ea66af9fa91df006106775d3073 (diff)
downloadmongodb-5d342a758c6095b4d30aba0750b54f13b8916f51.tar.gz
Imported Upstream version 2.0.0
Diffstat (limited to 'client/examples/httpClientTest.cpp')
-rw-r--r--client/examples/httpClientTest.cpp33
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
+
}