diff options
author | Eliot Horowitz <eliot@10gen.com> | 2009-07-17 15:49:24 -0400 |
---|---|---|
committer | Eliot Horowitz <eliot@10gen.com> | 2009-07-17 15:49:24 -0400 |
commit | 45f29d0123e15287f3c9176edaba2c8ef137ded0 (patch) | |
tree | 5c30bcf996b840aad498ebb807ec70d83bdbcdbd /util | |
parent | e9ef23c72df9c7b1e4e510cbe3b3504eda281787 (diff) | |
download | mongo-45f29d0123e15287f3c9176edaba2c8ef137ded0.tar.gz |
beginnings of mms client
Diffstat (limited to 'util')
-rw-r--r-- | util/httpclient.cpp | 45 | ||||
-rw-r--r-- | util/httpclient.h | 14 |
2 files changed, 59 insertions, 0 deletions
diff --git a/util/httpclient.cpp b/util/httpclient.cpp new file mode 100644 index 00000000000..7b20303048e --- /dev/null +++ b/util/httpclient.cpp @@ -0,0 +1,45 @@ +// httpclient.cpp + +#include "httpclient.h" + +namespace mongo { + + int HttpClient::get( string url , map<string,string>& headers, stringstream& data ){ + uassert( "invalid url" , url.find( "http://" ) == 0 ); + url = url.substr( 7 ); + + string host , path; + if ( url.find( "/" ) == string::npos ){ + host = url; + path = "/"; + } + else { + host = url.substr( 0 , url.find( "/" ) ); + path = url.substr( url.find( "/" ) ); + } + + int port = 80; + uassert( "non standard port not supported yet" , host.find( ":" ) == string::npos ); + + cout << "host [" << host << "]" << endl; + cout << "path [" << path << "]" << endl; + cout << "port: " << port << endl; + + string req; + { + stringstream ss; + ss << "GET " << path << " HTTP/1.1\r\n"; + ss << "Host: " << host << "\r\n"; + ss << "Connection: Close\r\n"; + ss << "User-Agent: mongodb http client\r\n"; + ss << "\r\n"; + + req = ss.str(); + } + + cout << req << endl; + + return -1; + } + +} diff --git a/util/httpclient.h b/util/httpclient.h new file mode 100644 index 00000000000..d783c5a9ae0 --- /dev/null +++ b/util/httpclient.h @@ -0,0 +1,14 @@ +// httpclient.h + +#pragma once + +#include "../stdafx.h" + +namespace mongo { + + class HttpClient { + public: + int get( string url , map<string,string>& headers, stringstream& data ); + }; +} + |