fw4spl
ClientQt.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2018.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #pragma once
8 
9 #include "fwNetworkIO/config.hpp"
10 #include "fwNetworkIO/exceptions/ConnectionRefused.hpp"
11 #include "fwNetworkIO/exceptions/ContentNotFound.hpp"
12 #include "fwNetworkIO/exceptions/HostNotFound.hpp"
13 #include "fwNetworkIO/http/Request.hpp"
14 
15 #include <QNetworkReply>
16 #include <QtNetwork>
17 
18 namespace fwNetworkIO
19 {
20 namespace http
21 {
22 
27 {
28  unsigned int status_code;
29  std::string message;
30 };
31 
35 class FWNETWORKIO_CLASS_API ClientQt : public QObject
36 {
37 Q_OBJECT
38 
39 public:
44  FWNETWORKIO_API ClientQt();
45  FWNETWORKIO_API virtual ~ClientQt();
52  FWNETWORKIO_API QByteArray get(Request::sptr request);
53 
58  FWNETWORKIO_API std::string getFile(Request::sptr request);
59 
65  FWNETWORKIO_API Request::HeadersType head(Request::sptr request);
66 
72  FWNETWORKIO_API QByteArray post(Request::sptr request, const QByteArray& body);
73 
74 public Q_SLOTS:
76  void processError(QNetworkReply::NetworkError errorCode);
77 
78 private:
80  void computeHeaders(QNetworkRequest& request, const Request::HeadersType& headers);
81 
82 };
83 
84 } // namespace http
85 } // namespace fwNetworkIO
The namespace fwNetworkIO contains the primary methods to access network.
HTTP client using Qt Network.
Definition: ClientQt.hpp:35
std::map< std::string, std::string > HeadersType
Maps header name to its value.
Definition: Request.hpp:29
This structure represent an HTTP response.
Definition: ClientQt.hpp:26