|
MongoDB
2.0.3
|
00001 // httpclient.h 00002 00003 /* Copyright 2009 10gen Inc. 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 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 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 }
1.8.0