22 const TInt KMaxTransToPipeline = 5; |
22 const TInt KMaxTransToPipeline = 5; |
23 |
23 |
24 /** |
24 /** |
25 * The default 2-phase constructor to create a CHttpService instance |
25 * The default 2-phase constructor to create a CHttpService instance |
26 * |
26 * |
27 * @publishedAll |
|
28 * @prototype |
|
29 */ |
27 */ |
30 EXPORT_C CHttpService* CHttpService::NewL() |
28 EXPORT_C CHttpService* CHttpService::NewL() |
31 { |
29 { |
32 CHttpService* self = new(ELeave) CHttpService; |
30 CHttpService* self = new(ELeave) CHttpService; |
33 CleanupStack::PushL(self); |
31 CleanupStack::PushL(self); |
67 * @param @aStringId String ID |
61 * @param @aStringId String ID |
68 * @param aPtr String |
62 * @param aPtr String |
69 * |
63 * |
70 * @return KErrNotFound if the string ID is not found in the HTTP string pool |
64 * @return KErrNotFound if the string ID is not found in the HTTP string pool |
71 * otherwise KErrNone for success |
65 * otherwise KErrNone for success |
72 * |
66 */ |
73 * @publishedAll |
|
74 * @prototype |
|
75 */ |
|
76 |
|
77 EXPORT_C TInt CHttpService::String(TInt aStringId, TPtrC8& aPtr) |
67 EXPORT_C TInt CHttpService::String(TInt aStringId, TPtrC8& aPtr) |
78 { |
68 { |
79 RStringF str = iHttpServiceStruct->iHttpSession.StringPool().StringF(aStringId, RHTTPSession::GetTable()); |
69 RStringF str = iHttpServiceStruct->iHttpSession.StringPool().StringF(aStringId, RHTTPSession::GetTable()); |
80 aPtr.Set(str.DesC()); |
70 aPtr.Set(str.DesC()); |
81 return KErrNone; |
71 return KErrNone; |
82 } |
72 } |
83 |
|
84 /** |
73 /** |
85 * Set the proxy that applies to all HTTP client transactions that "this" |
74 * Set the proxy that applies to all HTTP client transactions that "this" |
86 * CHttpService instance creates |
75 * CHttpService instance creates |
87 * |
76 * |
88 * @param aProxyAddress Proxy address. [for ex; http://myproxy.org:8081] |
77 * @param aProxyAddress Proxy address. [for ex; http://myproxy.org:8081] |
141 /** |
128 /** |
142 * Set the maxuimum number of TCP connections[socket] CHttpService instance that can activated |
129 * Set the maxuimum number of TCP connections[socket] CHttpService instance that can activated |
143 * at any time. The default no. of connections that the CHttpService instance uses is 6. |
130 * at any time. The default no. of connections that the CHttpService instance uses is 6. |
144 * |
131 * |
145 * @param aValue aValue No. of connections |
132 * @param aValue aValue No. of connections |
146 * |
|
147 * @publishedAll |
|
148 * @prototype |
|
149 */ |
133 */ |
150 |
134 |
151 EXPORT_C void CHttpService::SetMaxConnections(TInt aValue) |
135 EXPORT_C void CHttpService::SetMaxConnections(TInt aValue) |
152 { |
136 { |
153 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
137 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
177 } |
159 } |
178 return 0; |
160 return 0; |
179 } |
161 } |
180 |
162 |
181 |
163 |
182 /** |
|
183 * Sets the maximum number of transactions to be pipelined. |
|
184 * @param aValue - number of transactions |
|
185 * |
|
186 * @publishedAll |
|
187 * @prototype |
|
188 */ |
|
189 EXPORT_C void CHttpService::SetMaxTransactionsToPipeline(TInt aValue) |
164 EXPORT_C void CHttpService::SetMaxTransactionsToPipeline(TInt aValue) |
190 { |
165 { |
191 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
166 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
192 RStringPool sp = sess.StringPool(); |
167 RStringPool sp = sess.StringPool(); |
193 RHTTPConnectionInfo connInfo = sess.ConnectionInfo(); |
168 RHTTPConnectionInfo connInfo = sess.ConnectionInfo(); |
194 |
169 |
195 connInfo.SetProperty(sp.StringF(HTTP::EMaxNumTransactionsToPipeline, RHTTPSession::GetTable()), THTTPHdrVal(aValue)); |
170 connInfo.SetProperty(sp.StringF(HTTP::EMaxNumTransactionsToPipeline, RHTTPSession::GetTable()), THTTPHdrVal(aValue)); |
196 } |
171 } |
197 |
172 |
198 /** |
|
199 * Returns the maximum number of transactions to be pipelined. |
|
200 * |
|
201 * @publishedAll |
|
202 * @prototype |
|
203 */ |
|
204 EXPORT_C TInt CHttpService::MaxTransactionsToPipeline() const |
173 EXPORT_C TInt CHttpService::MaxTransactionsToPipeline() const |
205 { |
174 { |
206 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
175 RHTTPSession sess = iHttpServiceStruct->iHttpSession; |
207 RStringPool sp = sess.StringPool(); |
176 RStringPool sp = sess.StringPool(); |
208 RHTTPConnectionInfo connInfo = sess.ConnectionInfo(); |
177 RHTTPConnectionInfo connInfo = sess.ConnectionInfo(); |
218 /** |
187 /** |
219 * This method facilitates to set the header once in the CHttpService instance that is applicable |
188 * This method facilitates to set the header once in the CHttpService instance that is applicable |
220 * for all HTTP client transactions. [For ex; User-Agent header] |
189 * for all HTTP client transactions. [For ex; User-Agent header] |
221 * |
190 * |
222 * @param aStringId - Pre-defined String ID in the HTTP string pool |
191 * @param aStringId - Pre-defined String ID in the HTTP string pool |
223 * @param aHeaderValue - Value for the header |
192 * @param aHeaderValue - Value for the header |
224 * |
|
225 * @publishedAll |
|
226 * @prototype |
|
227 */ |
193 */ |
228 EXPORT_C TInt CHttpService::AddRequestHeader(TInt aStringId, const THttpHeaderValueVariant& aHeaderValue) |
194 EXPORT_C TInt CHttpService::AddRequestHeader(TInt aStringId, const THttpHeaderValueVariant& aHeaderValue) |
229 { |
195 { |
230 RHTTPHeaders sessHeaders = iHttpServiceStruct->iSessionHeaders; |
196 RHTTPHeaders sessHeaders = iHttpServiceStruct->iSessionHeaders; |
231 RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool(); |
197 RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool(); |
238 /** |
204 /** |
239 * This method facilitates to set the custom HTTP header once in the CHttpService instance that is |
205 * This method facilitates to set the custom HTTP header once in the CHttpService instance that is |
240 * applicable for all HTTP client transactions. [For ex; User-Agent header] |
206 * applicable for all HTTP client transactions. [For ex; User-Agent header] |
241 * |
207 * |
242 * @param aHeaderName - Custom header name |
208 * @param aHeaderName - Custom header name |
243 * @param aHeaderValue - Value for the header |
209 * @param aHeaderValue - Value for the header |
244 * |
|
245 * @publishedAll |
|
246 * @prototype |
|
247 */ |
210 */ |
248 EXPORT_C TInt CHttpService::AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue) |
211 EXPORT_C TInt CHttpService::AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue) |
249 { |
212 { |
250 _LIT8(KFieldSeparator, "\n"); |
213 _LIT8(KFieldSeparator, "\n"); |
251 RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool(); |
214 RStringPool sp = iHttpServiceStruct->iHttpSession.StringPool(); |
257 TInt err = iHttpServiceStruct->iSessionHeaders.SetRawField(str, aHeaderValue, KFieldSeparator); |
220 TInt err = iHttpServiceStruct->iSessionHeaders.SetRawField(str, aHeaderValue, KFieldSeparator); |
258 str.Close(); |
221 str.Close(); |
259 return err; |
222 return err; |
260 } |
223 } |
261 |
224 |
262 /** |
|
263 * This method facilitates to set to construct the authentication credentials to be passed by the application |
|
264 * The derived class from MHTTPServiceAuthentication will be called from the framework, if authentication is required. |
|
265 * @param aCallback - Derived class from MHTTPServiceAuthentication |
|
266 * |
|
267 * @publishedAll |
|
268 * @prototype |
|
269 */ |
|
270 EXPORT_C TInt CHttpService::SetAuthentication(MHTTPServiceAuthentication* aCallback) |
225 EXPORT_C TInt CHttpService::SetAuthentication(MHTTPServiceAuthentication* aCallback) |
271 { |
226 { |
272 TInt error = KErrGeneral; |
227 TInt error = KErrGeneral; |
273 iHttpServiceStruct->iHttpClientAuthentication = CHttpClientAuthentication::New(iHttpServiceStruct->iHttpSession, aCallback); |
228 iHttpServiceStruct->iHttpClientAuthentication = CHttpClientAuthentication::New(iHttpServiceStruct->iHttpSession, aCallback); |
274 if(iHttpServiceStruct->iHttpClientAuthentication) |
229 if(iHttpServiceStruct->iHttpClientAuthentication) |
291 iHttpServiceStruct->iSessionHeaders = iHttpServiceStruct->iHttpSession.RequestSessionHeadersL(); |
246 iHttpServiceStruct->iSessionHeaders = iHttpServiceStruct->iHttpSession.RequestSessionHeadersL(); |
292 SetMaxConnections(KMaxNoOfConnections); |
247 SetMaxConnections(KMaxNoOfConnections); |
293 SetMaxTransactionsToPipeline(KMaxTransToPipeline); |
248 SetMaxTransactionsToPipeline(KMaxTransToPipeline); |
294 } |
249 } |
295 |
250 |
296 /** |
|
297 * returns the CHttpNetworkConnection instance created by the framework. |
|
298 * The class can be used to set the connection properties. |
|
299 * |
|
300 * @publishedAll |
|
301 * @prototype |
|
302 */ |
|
303 EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection() |
251 EXPORT_C CHttpNetworkConnection* CHttpService::HttpNetworkConnection() |
304 { |
252 { |
305 CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New(); |
253 CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New(); |
306 httpNetworkConn->SetHttpService(this); |
254 httpNetworkConn->SetHttpService(this); |
307 return httpNetworkConn; |
255 return httpNetworkConn; |
308 } |
256 } |
309 |
|
310 void CHttpService::RemoveUnwantedFilters() |
|
311 { |
|
312 THTTPFilterRegistration filterInfo; |
|
313 RStringPool stringPool = iHttpServiceStruct->iHttpSession.StringPool(); |
|
314 |
|
315 RHTTPFilterCollection filterArray = iHttpServiceStruct->iHttpSession.FilterCollection(); |
|
316 THTTPFilterIterator iter = filterArray.Query(); |
|
317 const TStringTable& st = RHTTPSession::GetTable(); |
|
318 |
|
319 iter.First(); |
|
320 |
|
321 while (!iter.AtEnd()) |
|
322 { |
|
323 // Get next filter registration info |
|
324 filterInfo = iter(); |
|
325 RStringF filterName = stringPool.StringF(filterInfo.iName); |
|
326 switch(filterName.Index(st)) |
|
327 { |
|
328 //dont remove these filters |
|
329 case HTTP::EClient: |
|
330 case HTTP::EProtocolHandler: |
|
331 case HTTP::EValidation: |
|
332 case HTTP::ERedirect: |
|
333 case HTTP::EHttpConnectFilter: |
|
334 break; |
|
335 //anything other than above, remove. |
|
336 default: |
|
337 filterArray.RemoveFilter(filterName); |
|
338 } |
|
339 ++iter; |
|
340 } |
|
341 } |
|