2
* Copyright (C) 2010, 2011 Tuomo Penttinen, all rights reserved.
4
* Author: Tuomo Penttinen <tp@herqq.org>
6
* This file is part of Herqq UPnP (HUPnP) library.
8
* Herqq UPnP is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Lesser General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
13
* Herqq UPnP is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public License
19
* along with Herqq UPnP. If not, see <http://www.gnu.org/licenses/>.
22
#ifndef HHTTP_SERVER_P_H_
23
#define HHTTP_SERVER_P_H_
28
// This file is not part of public API and it should
29
// never be included in client code. The contents of this file may
30
// change or the file may be removed without of notice.
33
#include <HUpnpCore/HUpnp>
34
#include <HUpnpCore/private/hhttp_asynchandler_p.h>
35
#include <HUpnpCore/private/hhttp_messaginginfo_p.h>
37
#include <QtNetwork/QTcpServer>
50
class HSubscribeRequest;
51
class HUnsubscribeRequest;
52
class HInvokeActionRequest;
55
// Private class for handling HTTP server duties needed in UPnP messaging
57
class H_UPNP_CORE_EXPORT HHttpServer :
61
H_DISABLE_COPY(HHttpServer)
69
H_DISABLE_COPY(Server)
75
virtual void incomingConnection(qint32 socketDescriptor);
78
Server(HHttpServer* owner);
83
void msgIoComplete(HHttpAsyncOperation* op);
87
QList<Server*> m_servers;
91
const QByteArray m_loggingIdentifier;
92
HHttpAsyncHandler* m_httpHandler;
93
HChunkedInfo m_chunkedInfo;
94
qint32 m_maxBytesToLoad;
98
void processRequest(HHttpAsyncOperation*);
99
void processResponse(HHttpAsyncOperation*);
101
void processRequest(qint32 socketDescriptor);
103
void processNotifyMessage(
104
HMessagingInfo*, const HHttpRequestHeader&, const QByteArray& body);
107
HMessagingInfo*, const HHttpRequestHeader&);
110
HMessagingInfo*, const HHttpRequestHeader&);
113
HMessagingInfo*, const HHttpRequestHeader&, const QByteArray& body);
115
void processSubscription(
116
HMessagingInfo*, const HHttpRequestHeader&);
118
void processUnsubscription(
119
HMessagingInfo*, const HHttpRequestHeader&);
121
bool setupIface(const HEndpoint&);
125
virtual void incomingSubscriptionRequest(
126
HMessagingInfo*, const HSubscribeRequest&);
128
virtual void incomingUnsubscriptionRequest(
129
HMessagingInfo*, const HUnsubscribeRequest&);
131
virtual void incomingControlRequest(
132
HMessagingInfo*, const HInvokeActionRequest&);
134
virtual void incomingNotifyMessage(
135
HMessagingInfo*, const HNotifyRequest&);
137
virtual void incomingUnknownHeadRequest(
138
HMessagingInfo*, const HHttpRequestHeader&);
140
virtual void incomingUnknownGetRequest(
141
HMessagingInfo*, const HHttpRequestHeader&);
143
virtual void incomingUnknownPostRequest(
144
HMessagingInfo*, const HHttpRequestHeader&, const QByteArray& body);
146
virtual void incomingResponse(HHttpAsyncOperation*);
148
virtual bool sendComplete(HHttpAsyncOperation*);
152
HHttpServer(const QByteArray& loggingIdentifier, QObject* parent = 0);
153
virtual ~HHttpServer();
155
QList<QUrl> rootUrls() const;
156
QUrl rootUrl(const QHostAddress&) const;
157
QList<HEndpoint> endpoints() const;
158
inline qint32 endpointCount() const { return m_servers.size(); }
161
bool init(const HEndpoint&);
162
bool init(const QList<HEndpoint>&);
163
bool isInitialized() const;
166
qint32 maxBytesToLoad() const;
172
#endif /* HHTTP_SERVER_P_H_ */