There was no '?' between path and query. Bug detected by someone on the internet.
[contrib/qtwebsockets.git] / src / handshakeresponse_p.h
1 /*
2 QWebSockets implements the WebSocket protocol as defined in RFC 6455.
3 Copyright (C) 2013 Kurt Pattyn (pattyn.kurt@gmail.com)
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18 */
19
20 #ifndef HANDSHAKERESPONSE_P_H
21 #define HANDSHAKERESPONSE_P_H
22 //
23 //  W A R N I N G
24 //  -------------
25 //
26 // This file is not part of the Qt API.  It exists purely as an
27 // implementation detail.  This header file may change from version to
28 // version without notice, or even be removed.
29 //
30 // We mean it.
31 //
32
33 #include <QObject>
34 #include "qwebsocketprotocol.h"
35
36 QT_BEGIN_NAMESPACE
37
38 class HandshakeRequest;
39 class QString;
40 class QTextStream;
41
42 class HandshakeResponse:public QObject
43 {
44     Q_OBJECT
45 public:
46     HandshakeResponse(const HandshakeRequest &request,
47                       const QString &serverName,
48                       bool isOriginAllowed,
49                       const QList<QWebSocketProtocol::Version> &supportedVersions,
50                       const QList<QString> &supportedProtocols,
51                       const QList<QString> &supportedExtensions);
52
53     virtual ~HandshakeResponse();
54
55     bool isValid() const;
56     bool canUpgrade() const;
57     QString getAcceptedProtocol() const;
58     QString getAcceptedExtension() const;
59     QWebSocketProtocol::Version getAcceptedVersion() const;
60
61 public Q_SLOTS:
62
63 Q_SIGNALS:
64
65 private:
66     Q_DISABLE_COPY(HandshakeResponse)
67     bool m_isValid;
68     bool m_canUpgrade;
69     QString m_response;
70     QString m_acceptedProtocol;
71     QString m_acceptedExtension;
72     QWebSocketProtocol::Version m_acceptedVersion;
73
74     QString calculateAcceptKey(const QString &key) const;
75     QString getHandshakeResponse(const HandshakeRequest &request,
76                                  const QString &serverName,
77                                  bool isOriginAllowed,
78                                  const QList<QWebSocketProtocol::Version> &supportedVersions,
79                                  const QList<QString> &supportedProtocols,
80                                  const QList<QString> &supportedExtensions);
81
82     QTextStream &writeToStream(QTextStream &textStream) const;
83     friend QTextStream &operator <<(QTextStream &stream, const HandshakeResponse &response);
84 };
85
86 QT_END_NAMESPACE
87
88 #endif // HANDSHAKERESPONSE_P_H