bbc23b975ae31a88862d8207a9aa83c27b5bfcb6
[m6w6/libmemcached] / libtest / http.hpp
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * libtest
4 *
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 3 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22
23 #pragma once
24
25 namespace libtest {
26 namespace http {
27
28 class HTTP {
29 public:
30
31 HTTP(const std::string& url_arg);
32
33 virtual bool execute()= 0;
34
35 virtual ~HTTP()
36 { }
37
38 const std::string& url() const
39 {
40 return _url;
41 }
42
43 long response()
44 {
45 return _response;
46 }
47
48 private:
49 std::string _url;
50
51 protected:
52 long _response;
53 };
54
55 class GET: public HTTP {
56 public:
57
58 GET(const std::string& url_arg) :
59 HTTP(url_arg)
60 {
61 }
62
63 bool execute();
64
65 private:
66 libtest::vchar_t _body;
67 };
68
69 class POST: public HTTP {
70 public:
71
72 POST(const std::string& url_arg,
73 const vchar_t& post_arg) :
74 HTTP(url_arg),
75 _post(post_arg)
76 {
77 }
78
79 bool execute();
80
81 private:
82 libtest::vchar_t _post;
83 libtest::vchar_t _body;
84 };
85
86 class TRACE: public HTTP {
87 public:
88
89 TRACE(const std::string& url_arg,
90 const vchar_t& body_arg) :
91 HTTP(url_arg),
92 _body(body_arg)
93 {
94 }
95
96 bool execute();
97
98 private:
99 libtest::vchar_t _body;
100 };
101
102 class HEAD: public HTTP {
103 public:
104
105 HEAD(const std::string& url_arg) :
106 HTTP(url_arg)
107 {
108 }
109
110 bool execute();
111
112 private:
113 };
114
115 } // namespace http
116 } // namespace libtest