|
1 /** @file |
|
2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declares HttpMessageFactory class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_RUPNPHTTPMESSAGEFACTORY_H |
|
20 #define C_RUPNPHTTPMESSAGEFACTORY_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "upnphttpmessage.h" |
|
25 |
|
26 |
|
27 // ================= MEMBER FUNCTIONS ======================= |
|
28 /*! |
|
29 \brief HTTP Message Factory. Used to create standard HTTP messages. |
|
30 |
|
31 */ |
|
32 |
|
33 class RUpnpHttpMessageFactory |
|
34 { |
|
35 public: |
|
36 |
|
37 /** |
|
38 Constructor function; Creates HTTP get message, which is used normally to get content from remote servers. |
|
39 @param aDestination Destination of the message. |
|
40 @param aPath path to file in Http server. |
|
41 @return new Http message. |
|
42 **/ |
|
43 IMPORT_C static CUpnpHttpMessage* HttpGetL(TInetAddr& aDestination, const TDesC8& aPath); |
|
44 |
|
45 /** |
|
46 Constructor function; Creates HTTP get message, which is used normally to get content from remote servers. |
|
47 @param aDestination Destination of the message. |
|
48 @param aHeadPath Start path to file in Http server. |
|
49 @param aTailPath End path to file in Http server. |
|
50 @return new Http message. |
|
51 **/ |
|
52 IMPORT_C static CUpnpHttpMessage* HttpGetL(TInetAddr& aDestination, const TDesC8& aHeadPath, const TDesC8& aTailPath); |
|
53 |
|
54 /** |
|
55 Constructor function; Creates HTTP get message, which is used normally to get content from remote servers. |
|
56 @param aUrl Url to file. |
|
57 @return new Http message. |
|
58 **/ |
|
59 IMPORT_C static CUpnpHttpMessage* HttpGetL(const TDesC8& aUrl); |
|
60 |
|
61 /** |
|
62 Constructor function; Creates HTTP get message, which is used normally to get content from remote servers. |
|
63 @param aDestination Destination of the message. |
|
64 @param aPath path to file in Http server. |
|
65 @return new Http message. |
|
66 **/ |
|
67 IMPORT_C static CUpnpHttpMessage* HttpGetL(const TDesC8& aDestination, const TDesC8& aPath); |
|
68 |
|
69 /** |
|
70 Constructor function; Creates HTTP HEAD message. |
|
71 @param aUrl Url to file/target/service. |
|
72 @return new Http message. |
|
73 **/ |
|
74 IMPORT_C static CUpnpHttpMessage* HttpHeadL(const TDesC8& aUrl); |
|
75 |
|
76 /** |
|
77 Constructor function; Creates HTTP HEAD message. |
|
78 @param aDestination Destination of the message. |
|
79 @param aPath path to file in Http server. |
|
80 @return new Http message. |
|
81 **/ |
|
82 IMPORT_C static CUpnpHttpMessage* HttpHeadL(const TDesC8& aDestination, const TDesC8& aPath); |
|
83 |
|
84 /** |
|
85 Constructor function; Creates HTTP HEAD message. |
|
86 @param aDestination Destination of the message. |
|
87 @param aPath path to file in Http server. |
|
88 @return new Http message. |
|
89 **/ |
|
90 IMPORT_C static CUpnpHttpMessage* HttpHeadL( TInetAddr& aDestination, const TDesC8& aPath); |
|
91 |
|
92 /** |
|
93 Constructor function; Creates HTTP POST message. |
|
94 @param aUrl Url to file/target/service. |
|
95 @return new Http message. |
|
96 **/ |
|
97 IMPORT_C static CUpnpHttpMessage* HttpPostL(const TDesC8& aUrl); |
|
98 |
|
99 /** |
|
100 Constructor function; Creates HTTP POST message. |
|
101 @param aDestination Destination of the message. |
|
102 @param aPath path to file in Http server. |
|
103 @return new Http message. |
|
104 **/ |
|
105 IMPORT_C static CUpnpHttpMessage* HttpPostL(const TDesC8& aDestination, const TDesC8& aPath); |
|
106 |
|
107 /** |
|
108 Constructor function; Creates HTTP POST message. |
|
109 @param aDestination Destination of the message. |
|
110 @param aPath path to file in Http server. |
|
111 @return new Http message. |
|
112 **/ |
|
113 IMPORT_C static CUpnpHttpMessage* HttpPostL(const TInetAddr& aDestination, const TDesC8& aPath); |
|
114 |
|
115 /** |
|
116 Creates a HTTP OK reply message, Code 200. |
|
117 @param aMessage Message in which should be replied. |
|
118 @return new Http message. |
|
119 **/ |
|
120 IMPORT_C static CUpnpHttpMessage* HttpResponseOkL(CUpnpHttpMessage* aMessage); |
|
121 |
|
122 /** |
|
123 Creates a HTTP OK reply message, Code 200. |
|
124 @param aDestination Destination of the reply message. |
|
125 @return new Http message. |
|
126 **/ |
|
127 IMPORT_C static CUpnpHttpMessage* HttpResponseOkL(const TInetAddr& aDestination); |
|
128 |
|
129 /** |
|
130 Creates a HTTP reply message. |
|
131 @param aMessage Message in which should be replied. |
|
132 @param aStatus Number of status code. |
|
133 @return new Http message. |
|
134 **/ |
|
135 IMPORT_C static CUpnpHttpMessage* Http11ResponseL( CUpnpHttpMessage *aMessage, TInt aStatus ); |
|
136 |
|
137 /** |
|
138 Creates a HTTP reply message. |
|
139 @param aDestination Destination of the reply message. |
|
140 @param aStatus Number of status code. |
|
141 @return new Http message. |
|
142 **/ |
|
143 IMPORT_C static CUpnpHttpMessage* Http11ResponseL( const TInetAddr& aDestination, TInt aStatus ); |
|
144 |
|
145 /** |
|
146 Creates a HTTP Error message. |
|
147 @param aMessage Message in which should be replied. |
|
148 @param aError Number of error code. |
|
149 @return new Http message. |
|
150 **/ |
|
151 IMPORT_C static CUpnpHttpMessage* HttpResponseErrorL(CUpnpHttpMessage* aMessage, TInt aError); |
|
152 |
|
153 /** |
|
154 Creates a HTTP Error message. |
|
155 @param aAddr Destination of the error message. |
|
156 @param aError Number of error code. |
|
157 @return new Http message. |
|
158 **/ |
|
159 IMPORT_C static CUpnpHttpMessage* HttpResponseErrorL(const TInetAddr& aAddr, TInt aError); |
|
160 |
|
161 /** |
|
162 Creates a HTTP Error message with UPnp error codes. |
|
163 @param aMessage Message in which should be replied. |
|
164 @param aError Number of error code. |
|
165 @return new Http message. |
|
166 **/ |
|
167 IMPORT_C static CUpnpHttpMessage* UpnpResponseErrorL(CUpnpHttpMessage* aMessage, TUpnpErrorCode aError); |
|
168 |
|
169 /** |
|
170 Creates a HTTP Error message with UPnp error codes. |
|
171 @param aDestination Destination of the error message. |
|
172 @param aError Number of error code. |
|
173 @return new Http message. |
|
174 **/ |
|
175 IMPORT_C static CUpnpHttpMessage* UpnpResponseErrorL(const TInetAddr& aDestination, TUpnpErrorCode aError); |
|
176 |
|
177 private: |
|
178 |
|
179 /** |
|
180 Sets Host HTTP header to given message basing on given destinstion address. |
|
181 @param aMessage Message for which the Host header will be set. |
|
182 @param aDestination Destination address. |
|
183 **/ |
|
184 static void SetHostHeaderL( CUpnpHttpMessage* aMessage, const TInetAddr& aDestination ); |
|
185 }; |
|
186 |
|
187 |
|
188 #endif // C_RUPNPHTTPMESSAGEFACTORY_H |