0
|
1 |
/*
|
|
2 |
============================================================================
|
|
3 |
Name : HttpClient.h
|
|
4 |
Author : John Kern
|
|
5 |
|
|
6 |
Copyright (c) 2009 Symbian Foundation Ltd
|
|
7 |
This component and the accompanying materials are made available
|
|
8 |
under the terms of the License "Eclipse Public License v1.0"
|
|
9 |
which accompanies this distribution, and is available
|
|
10 |
at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
11 |
|
|
12 |
Initial Contributors:
|
|
13 |
- Symbian Foundation Ltd - initial contribution.
|
|
14 |
|
|
15 |
Contributors:
|
|
16 |
- John Kern
|
|
17 |
- Symsource
|
|
18 |
|
|
19 |
Description : This file contains panic codes.
|
|
20 |
============================================================================
|
|
21 |
*/
|
|
22 |
|
|
23 |
#ifndef __HTTP_CLIENT_H_
|
|
24 |
#define __HTTP_CLIENT_H_
|
|
25 |
|
|
26 |
#include <es_sock.h>
|
|
27 |
#include <http/mhttpdatasupplier.h>
|
|
28 |
#include <http/mhttptransactioncallback.h>
|
|
29 |
#include <http/rhttpheaders.h>
|
|
30 |
#include <http/RHTTPSession.h>
|
|
31 |
|
|
32 |
#include "NPRStoryXmlParser.h"
|
|
33 |
|
|
34 |
class MHTTPObserver
|
|
35 |
{
|
|
36 |
public:
|
|
37 |
virtual void ResponseStatusL(TInt aStatusCode, const TDesC& aStatusText) = 0;
|
|
38 |
virtual void ResponseReceivedL(const TDesC8& aResponseBuffer) = 0;
|
|
39 |
};
|
|
40 |
|
|
41 |
/*
|
|
42 |
* This class implements the http request response sequence using RHTTPSession
|
|
43 |
* class. The IAP selection is not done silently and needs user input.
|
|
44 |
*/
|
|
45 |
|
|
46 |
class CHttpClient : public CBase,
|
|
47 |
public MHTTPTransactionCallback,
|
|
48 |
public MHTTPDataSupplier
|
|
49 |
{
|
|
50 |
public:
|
|
51 |
static CHttpClient* NewL(MHTTPObserver& aObserver);
|
|
52 |
virtual ~CHttpClient();
|
|
53 |
|
|
54 |
public:
|
|
55 |
void SendRequestL(const TDesC& aUri);
|
|
56 |
|
|
57 |
//From MHTTPTransactionCallback
|
|
58 |
void MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
|
|
59 |
TInt MHFRunError(TInt aError, RHTTPTransaction aTransaction, const THTTPEvent &aEvent);
|
|
60 |
|
|
61 |
//From MHTTPDataSupplier
|
|
62 |
TBool GetNextDataPart(TPtrC8& aDataPart);
|
|
63 |
void ReleaseData();
|
|
64 |
TInt OverallDataSize();
|
|
65 |
TInt Reset();
|
|
66 |
|
|
67 |
private:
|
|
68 |
void AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8& aHeaderValue);
|
|
69 |
void AddHeaderL(RHTTPHeaders aHeaders, TInt aHeaderField, const TDesC8& aHeaderValue, TInt aExtensionField, const TDesC8& aExtensionValue);
|
|
70 |
|
|
71 |
private:
|
|
72 |
CHttpClient(MHTTPObserver& aObserver);
|
|
73 |
void ConstructL();
|
|
74 |
|
|
75 |
private:
|
|
76 |
RHTTPSession iHTTPSession;
|
|
77 |
MHTTPObserver& iObserver;
|
|
78 |
RSocketServ iSocketServ;
|
|
79 |
RConnection iConnection;
|
|
80 |
RHTTPTransaction iHttpTransaction;
|
|
81 |
RHTTPConnectionInfo iHttpConnInfo;
|
|
82 |
HBufC8* iResponseBuffer; // The buffers to hold the request and response bodies.
|
|
83 |
HBufC8* iUri;
|
|
84 |
TBool iTransactionActive;
|
|
85 |
};
|
|
86 |
|
|
87 |
#endif /* __HTTP_CLIENT_H_ */
|