|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "thttpconnectcallback.h" |
|
17 |
|
18 #include <http/mhttpdatasupplier.h> |
|
19 |
|
20 #include "mhttpconnectobserver.h" |
|
21 |
|
22 |
|
23 THttpConnectCallback::THttpConnectCallback(MHttpConnectObserver& aObserver) |
|
24 : iObserver(aObserver) |
|
25 { |
|
26 } |
|
27 |
|
28 /* |
|
29 * Methods from MHTTPTransactionCallback |
|
30 */ |
|
31 |
|
32 void THttpConnectCallback::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent) |
|
33 { |
|
34 switch( aEvent.iStatus ) |
|
35 { |
|
36 case THTTPEvent::EGotResponseHeaders: |
|
37 { |
|
38 // @todo could have a callback that notifies someone of CONNECT response headers... |
|
39 } break; |
|
40 case THTTPEvent::EResponseComplete: |
|
41 { |
|
42 // Inform the observer that this CONNECT transaction has succeeded. |
|
43 iObserver.ConnectCompleteL(aTransaction.Id()); |
|
44 } break; |
|
45 case THTTPEvent::EGotResponseBodyData: |
|
46 { |
|
47 // Just release the body data, as it is of no use! |
|
48 MHTTPDataSupplier* data = aTransaction.Response().Body(); |
|
49 data->ReleaseData(); |
|
50 } break; |
|
51 case THTTPEvent::ERedirectRequiresConfirmation: |
|
52 case THTTPEvent::ENeedTunnel: |
|
53 case THTTPEvent::EGotResponseTrailerHeaders: |
|
54 { |
|
55 // Should not be receiving these events |
|
56 User::Invariant(); |
|
57 } break; |
|
58 case THTTPEvent::EFailed: |
|
59 { |
|
60 // Inform the observer that the CONNECT transaction has failed. |
|
61 iObserver.ConnectErrorL(aTransaction.Id()); |
|
62 } break; |
|
63 |
|
64 case THTTPEvent::ESucceeded: |
|
65 case THTTPEvent::EUnrecoverableError: |
|
66 default: |
|
67 // Do nothing - Succeeded handled by response complete, failed handled by Failed States |
|
68 break; |
|
69 }; |
|
70 } |
|
71 |
|
72 TInt THttpConnectCallback::MHFRunError(TInt /*aError*/, RHTTPTransaction aTransaction, const THTTPEvent& /*aEvent*/) |
|
73 { |
|
74 iObserver.FailPendingTransactions(aTransaction.Id()); |
|
75 return KErrNone; |
|
76 } |