|
1 /* |
|
2 * Copyright (c) 2002-2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include <uri8.h> |
|
26 #include <e32base.h> |
|
27 #include <http.h> |
|
28 #include "senhttpchannelimpl.h" |
|
29 #include "senhttpeventhandler.h" |
|
30 #include <e32std.h> |
|
31 |
|
32 #include "sendebug.h" |
|
33 #include "senlogger.h" |
|
34 |
|
35 // |
|
36 // Implementation of class CSenHttpEventHandler |
|
37 // |
|
38 |
|
39 void CSenHttpEventHandler::ConstructL() |
|
40 { |
|
41 } |
|
42 |
|
43 |
|
44 CSenHttpEventHandler::CSenHttpEventHandler(CSenHttpChannelImpl* aChannel)//, |
|
45 //RFileLogger* aLog) |
|
46 : iHttpChannel(aChannel), |
|
47 //iLog(aLog), |
|
48 iTries(0) |
|
49 { |
|
50 } |
|
51 |
|
52 CSenHttpEventHandler::~CSenHttpEventHandler() |
|
53 { |
|
54 } |
|
55 |
|
56 CSenHttpEventHandler* CSenHttpEventHandler::NewLC( |
|
57 CSenHttpChannelImpl* aChannel)//, |
|
58 //RFileLogger* aLog) |
|
59 { |
|
60 CSenHttpEventHandler* pNew = |
|
61 new (ELeave) CSenHttpEventHandler(aChannel);//, aLog); |
|
62 CleanupStack::PushL(pNew); |
|
63 pNew->ConstructL(); |
|
64 return pNew; |
|
65 } |
|
66 |
|
67 CSenHttpEventHandler* CSenHttpEventHandler::NewL(CSenHttpChannelImpl* aChannel)//, |
|
68 //RFileLogger* aLog) |
|
69 { |
|
70 CSenHttpEventHandler* pNew = NewLC(aChannel);//, aLog); |
|
71 CleanupStack::Pop(pNew); |
|
72 return pNew; |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // CSenHttpEventHandler::MHFRunL |
|
77 // Handle Http stack events. |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CSenHttpEventHandler::MHFRunL(RHTTPTransaction aTransaction, |
|
81 const THTTPEvent& aEvent) |
|
82 { |
|
83 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("CSenHttpEventHandler::MHFRunL( %d )"), aEvent.iStatus)); |
|
84 if (aEvent.iStatus < 0) |
|
85 { |
|
86 if (aEvent.iStatus == KErrDisconnected) |
|
87 { |
|
88 aTransaction.Cancel(); |
|
89 TRAPD(err, aTransaction.SubmitL()); |
|
90 if (err != KErrNone) |
|
91 { |
|
92 iHttpChannel->HandleRunErrorL(aTransaction, err); |
|
93 } |
|
94 } |
|
95 else |
|
96 { |
|
97 iHttpChannel->SetExplicitIapDefined(EFalse); |
|
98 iHttpChannel->HandleRunErrorL(aTransaction, aEvent.iStatus); |
|
99 } |
|
100 return; |
|
101 } |
|
102 |
|
103 switch (aEvent.iStatus) |
|
104 { |
|
105 case THTTPEvent::EGotResponseHeaders: |
|
106 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KNormalLogLevel, _L8("CSenHttpEventHandler::statuscode( %d )"), |
|
107 aTransaction.Response().StatusCode())); |
|
108 iHttpChannel->HandleResponseHeadersL(aTransaction); |
|
109 break; |
|
110 case THTTPEvent::EGotResponseBodyData: |
|
111 iHttpChannel->HandleResponseBodyDataL(aTransaction); |
|
112 iTries = 0; |
|
113 break; |
|
114 case THTTPEvent::EResponseComplete: |
|
115 break; |
|
116 case THTTPEvent::ESucceeded: |
|
117 iHttpChannel->HandleResponseL(aTransaction); |
|
118 break; |
|
119 case THTTPEvent::EFailed: |
|
120 case THTTPEvent::EMoreDataReceivedThanExpected: |
|
121 iHttpChannel->HandleRunErrorL(aTransaction, |
|
122 aTransaction.Response().StatusCode()); |
|
123 break; |
|
124 case THTTPEvent::EUnrecoverableError: |
|
125 iHttpChannel->HandleRunErrorL(aTransaction, KErrNoMemory); |
|
126 break; |
|
127 case THTTPEvent::ERedirectRequiresConfirmation: |
|
128 iHttpChannel->HandleRedirectRequiresConfirmationL(aTransaction); |
|
129 break; |
|
130 case THTTPEvent::ERedirectedPermanently: |
|
131 case THTTPEvent::ERedirectedTemporarily: |
|
132 case THTTPEvent::EGotResponseTrailerHeaders: |
|
133 break;// We don't process this event |
|
134 default: |
|
135 iHttpChannel->HandleRunErrorL(aTransaction, aEvent.iStatus); |
|
136 break; |
|
137 } |
|
138 if (aTransaction.Response().StatusCode() == 401 && iTries < 4) |
|
139 { |
|
140 iTries++; |
|
141 aTransaction.SubmitL(); |
|
142 } |
|
143 } |
|
144 |
|
145 TInt CSenHttpEventHandler::MHFRunError(TInt aError, |
|
146 RHTTPTransaction aTransaction, |
|
147 const THTTPEvent& /*aEvent*/) |
|
148 { |
|
149 TLSLOG_FORMAT((KSenHttpChannelLogChannelBase , KMinLogLevel, _L8("CSenHttpEventHandler::MHFRunError( %d )"), aError)); |
|
150 TRAP_IGNORE( iHttpChannel->HandleRunErrorL(aTransaction, aError); ) |
|
151 return KErrNone; |
|
152 } |
|
153 /* |
|
154 RFileLogger* CSenHttpEventHandler::Log() const |
|
155 { |
|
156 return iLog; |
|
157 } |
|
158 */ |
|
159 // EOF |
|
160 |
|
161 |
|
162 |