Torc  0.1
torchttpreader.h
Go to the documentation of this file.
1 #ifndef TORCHTTPREADER_H
2 #define TORCHTTPREADER_H
3 
4 // Qt
5 #include <QByteArray>
6 #include <QTcpSocket>
7 
9 {
10  friend class TorcWebSocket;
11 
12  public:
14  ~TorcHTTPReader() = default;
15 
16  void TakeRequest (QByteArray& Content, QMap<QString,QString>& Headers);
17  QString GetMethod (void) const;
18  bool Read (QTcpSocket *Socket);
19  bool IsReady (void) const;
20  bool HeadersComplete (void) const;
21 
22  protected:
23  void Reset (void);
24 
25  private:
26  bool m_ready;
27  bool m_requestStarted;
28  bool m_headersComplete;
29  int m_headersRead;
30  quint64 m_contentLength;
31  quint64 m_contentReceived;
32  QString m_method;
33  QByteArray m_content;
34  QMap<QString,QString> m_headers;
35 };
36 
37 #endif // TORCHTTPREADER_H
QString GetMethod(void) const
bool Read(QTcpSocket *Socket)
Read and parse data from the given socket.
Overlays the Websocket protocol over a QTcpSocket.
Definition: torcwebsocket.h:23
bool IsReady(void) const
A convenience class to read HTTP requests from a QTcpSocket.
Definition: torchttpreader.h:8
bool HeadersComplete(void) const
~TorcHTTPReader()=default
void TakeRequest(QByteArray &Content, QMap< QString, QString > &Headers)
Take ownership of the contents and headers. New owner is responsible for deleting.
void Reset(void)
Reset the read state.