1 /*
2 * Copyright (C) 2009 by Tommi Meakitalo
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * As a special exception, you may use this file as part of a free
10 * software library without restriction. Specifically, if other files
11 * instantiate templates or use macros or inline functions from this
12 * file, or you compile this file and link it with other files to
13 * produce an executable, this file does not by itself cause the
14 * resulting executable to be covered by the GNU General Public
15 * License. This exception does not however invalidate any other
16 * reasons why the executable file might be covered by the GNU Library
17 * General Public License.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27 */
28
29 #include "cxxtools/xmlrpc/httpclient.h"
30 #include "cxxtools/net/uri.h"
31 #include "httpclientimpl.h"
32
33 namespace cxxtools
34 {
35
36 namespace xmlrpc
37 {
38
HttpClient()39 HttpClient::HttpClient()
40 : _impl(new HttpClientImpl())
41 {
42 impl(_impl);
43 }
44
45
HttpClient(SelectorBase & selector,const std::string & server,unsigned short port,const std::string & url)46 HttpClient::HttpClient(SelectorBase& selector, const std::string& server,
47 unsigned short port, const std::string& url)
48 : _impl(new HttpClientImpl(selector, server, port, url))
49 {
50 impl(_impl);
51 }
52
53
HttpClient(SelectorBase & selector,const net::Uri & uri)54 HttpClient::HttpClient(SelectorBase& selector, const net::Uri& uri)
55 : _impl(new HttpClientImpl(selector, uri.host(), uri.port(), uri.path()))
56 {
57 impl(_impl);
58 auth(uri.user(), uri.password());
59 }
60
61
HttpClient(const std::string & server,unsigned short port,const std::string & url)62 HttpClient::HttpClient(const std::string& server, unsigned short port, const std::string& url)
63 : _impl(new HttpClientImpl(server, port, url))
64 {
65 impl(_impl);
66 }
67
68
HttpClient(const net::Uri & uri)69 HttpClient::HttpClient(const net::Uri& uri)
70 : _impl(new HttpClientImpl(uri.host(), uri.port(), uri.path()))
71 {
72 impl(_impl);
73 auth(uri.user(), uri.password());
74 }
75
76
~HttpClient()77 HttpClient::~HttpClient()
78 {
79 delete _impl;
80 }
81
connect(const net::AddrInfo & addrinfo,const std::string & url)82 void HttpClient::connect(const net::AddrInfo& addrinfo, const std::string& url)
83 {
84 _impl->connect(addrinfo, url);
85 }
86
connect(const net::Uri & uri)87 void HttpClient::connect(const net::Uri& uri)
88 {
89 _impl->connect(uri.host(), uri.port(), uri.path());
90 auth(uri.user(), uri.password());
91 }
92
connect(const std::string & addr,unsigned short port,const std::string & url)93 void HttpClient::connect(const std::string& addr, unsigned short port, const std::string& url)
94 {
95 _impl->connect(addr, port, url);
96 }
97
url(const std::string & url)98 void HttpClient::url(const std::string& url)
99 {
100 _impl->url(url);
101 }
102
auth(const std::string & username,const std::string & password)103 void HttpClient::auth(const std::string& username, const std::string& password)
104 {
105 _impl->auth(username, password);
106 }
107
clearAuth()108 void HttpClient::clearAuth()
109 {
110 _impl->clearAuth();
111 }
112
setSelector(SelectorBase & selector)113 void HttpClient::setSelector(SelectorBase& selector)
114 {
115 _impl->setSelector(selector);
116 }
117
wait(std::size_t msecs)118 void HttpClient::wait(std::size_t msecs)
119 {
120 _impl->wait(msecs);
121 }
122
123 }
124
125 }
126