Nuria Framework - Network
Network module of the NuriaProject Framework
 All Classes Functions Typedefs Enumerations Enumerator
httptcptransport.hpp
1 /* Copyright (c) 2014, The Nuria Project
2  * This software is provided 'as-is', without any express or implied
3  * warranty. In no event will the authors be held liable for any damages
4  * arising from the use of this software.
5  * Permission is granted to anyone to use this software for any purpose,
6  * including commercial applications, and to alter it and redistribute it
7  * freely, subject to the following restrictions:
8  * 1. The origin of this software must not be misrepresented; you must not
9  * claim that you wrote the original software. If you use this software
10  * in a product, an acknowledgment in the product documentation would be
11  * appreciated but is not required.
12  * 2. Altered source versions must be plainly marked as such, and must not be
13  * misrepresented as being the original software.
14  * 3. This notice may not be removed or altered from any source
15  * distribution.
16  */
17 
18 #ifndef NURIA_HTTPTCPTRANSPORT_HPP
19 #define NURIA_HTTPTCPTRANSPORT_HPP
20 
21 #include "httptransport.hpp"
22 
23 class QTcpSocket;
24 
25 namespace Nuria {
26 
27 class HttpTcpTransportPrivate;
28 
32 class NURIA_NETWORK_EXPORT HttpTcpTransport : public HttpTransport {
33  Q_OBJECT
34 public:
35 
37  explicit HttpTcpTransport (QTcpSocket *socket, QObject *parent = 0);
38 
40  ~HttpTcpTransport () override;
41 
42  //
43  Type type () const override;
44  bool isSecure () const override;
45  QHostAddress localAddress () const override;
46  quint16 localPort () const override;
47  QHostAddress peerAddress () const override;
48  quint16 peerPort () const override;
49 
50  bool isSequential () const override;
51  bool open (OpenMode mode) override;
52  void close () override;
53  qint64 pos () const override;
54  qint64 size () const override;
55  bool seek (qint64 pos) override;
56  bool atEnd () const override;
57  bool reset () override;
58  qint64 bytesAvailable () const override;
59  qint64 bytesToWrite () const override;
60  bool canReadLine () const override;
61  bool waitForReadyRead (int msecs) override;
62  bool waitForBytesWritten (int msecs) override;
63 
64 public slots:
65  bool flush () override;
66  void forceClose () override;
67 
68 private slots:
69  bool closeSocketWhenBytesWereWritten ();
70 
71 protected:
72  qint64 readData (char *data, qint64 maxlen) override;
73  qint64 readLineData (char *data, qint64 maxlen) override;
74  qint64 writeData (const char *data, qint64 len) override;
75 
76 private:
77  HttpTcpTransportPrivate *d_ptr;
78 
79 };
80 
81 }
82 
83 #endif // NURIA_HTTPTCPTRANSPORT_HPP
HttpClient transport for TCP with or without SSL connections.
Definition: httptcptransport.hpp:32
Type
Definition: httptransport.hpp:40
Abstract data transport for HttpClient.
Definition: httptransport.hpp:34