00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #pragma once
00019
00020 #include "../../pch.h"
00021 #include "sock.h"
00022
00023 namespace mongo {
00024
00025 class HttpClient : boost::noncopyable {
00026 public:
00027
00028 typedef map<string,string> Headers;
00029
00030 class Result {
00031 public:
00032 Result() {}
00033
00034 const string& getEntireResponse() const {
00035 return _entireResponse;
00036 }
00037
00038 const Headers getHeaders() const {
00039 return _headers;
00040 }
00041
00042 const string& getBody() const {
00043 return _body;
00044 }
00045
00046 private:
00047
00048 void _init( int code , string entire );
00049
00050 int _code;
00051 string _entireResponse;
00052
00053 Headers _headers;
00054 string _body;
00055
00056 friend class HttpClient;
00057 };
00058
00062 int get( string url , Result * result = 0 );
00063
00067 int post( string url , string body , Result * result = 0 );
00068
00069 private:
00070 int _go( const char * command , string url , const char * body , Result * result );
00071
00072 #ifdef MONGO_SSL
00073 void _checkSSLManager();
00074
00075 scoped_ptr<SSLManager> _sslManager;
00076 #endif
00077 };
00078 }
00079