MongoDB  2.7.0
httpclient.h
1 // httpclient.h
2 
3 /* Copyright 2009 10gen Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include "mongo/client/export_macros.h"
21 #include "mongo/pch.h"
22 
23 namespace mongo {
24 
25  class MONGO_CLIENT_API HttpClient : boost::noncopyable {
26  public:
27 
28  typedef map<string,string> Headers;
29 
30  class MONGO_CLIENT_API Result {
31  public:
32  Result() {}
33 
34  const string& getEntireResponse() const {
35  return _entireResponse;
36  }
37 
38  Headers getHeaders() const {
39  return _headers;
40  }
41 
42  const string& getBody() const {
43  return _body;
44  }
45 
46  private:
47 
48  void _init( int code , string entire );
49 
50  int _code;
51  string _entireResponse;
52 
53  Headers _headers;
54  string _body;
55 
56  friend class HttpClient;
57  };
58 
62  int get( const std::string& url , Result * result = 0 );
63 
67  int post( const std::string& url , const std::string& body , Result * result = 0 );
68 
69  private:
70  int _go( const char * command , string url , const char * body , Result * result );
71  };
72 }
Definition: httpclient.h:25
Definition: httpclient.h:30