|
1 /** @file |
|
2 * Copyright (c) 2008 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: Definition of the CUpnpHttpTransaction class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <upnphttpmessage.h> |
|
20 #include <upnpcons.h> |
|
21 #include <upnphttpmessagefactory.h> |
|
22 |
|
23 #include "upnphttptransaction.h" |
|
24 |
|
25 // ---------------------------------------------------------------------------- |
|
26 // CUpnpHttpTransaction::BaseConstructL |
|
27 // Second phase constructor intended to use by child classes. |
|
28 // ---------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C void CUpnpHttpTransaction::BaseConstructL() |
|
31 { |
|
32 iHttpRequest->AddPairL( UpnpHTTP::KConnection, UpnpHTTP::KClose ); |
|
33 } |
|
34 |
|
35 // ---------------------------------------------------------------------------- |
|
36 // CUpnpHttpTransaction::CUpnpHttpTransaction |
|
37 // Constructs object of transaction and takes ownership of request object |
|
38 // ---------------------------------------------------------------------------- |
|
39 // |
|
40 EXPORT_C CUpnpHttpTransaction::CUpnpHttpTransaction( CUpnpHttpMessage* aRequest ): |
|
41 iHttpRequest( aRequest ) |
|
42 { |
|
43 ASSERT( NULL != aRequest ); |
|
44 } |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // CUpnpHttpTransaction::~CUpnpHttpTransaction |
|
48 // Destructor. |
|
49 // ---------------------------------------------------------------------------- |
|
50 // |
|
51 EXPORT_C CUpnpHttpTransaction::~CUpnpHttpTransaction() |
|
52 { |
|
53 delete iHttpRequest; |
|
54 delete iHttpResponse; |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // CUpnpHttpTransaction::Request |
|
59 // Returns request message of transaction |
|
60 // ---------------------------------------------------------------------------- |
|
61 // |
|
62 EXPORT_C CUpnpHttpMessage* CUpnpHttpTransaction::Request() |
|
63 { |
|
64 return iHttpRequest; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CUpnpHttpTransaction::Response |
|
69 // Returns response message of transaction |
|
70 // ---------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C CUpnpHttpMessage* CUpnpHttpTransaction::Response() |
|
73 { |
|
74 return iHttpResponse; |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CUpnpHttpTransaction::CreateOkResponseL |
|
79 // Creates ok response for the request |
|
80 // ---------------------------------------------------------------------------- |
|
81 // |
|
82 void CUpnpHttpTransaction::CreateOkResponseL( const TDesC8& aResponseBody ) |
|
83 { |
|
84 ASSERT( NULL == iHttpResponse ); //only one ok response is allowed |
|
85 iHttpResponse = RUpnpHttpMessageFactory::HttpResponseOkL( iHttpRequest ); |
|
86 iHttpResponse->SetBodyL( aResponseBody ); |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CUpnpHttpTransaction::CreateFaultResponseL |
|
91 // Creates timeout response for the request |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 void CUpnpHttpTransaction::CreateFaultResponseL( const TDesC8& aResponseBody, |
|
95 TInt aStatus, |
|
96 TInt aError ) |
|
97 { |
|
98 delete iHttpResponse; |
|
99 iHttpResponse = NULL; |
|
100 iHttpResponse = RUpnpHttpMessageFactory::HttpResponseErrorL( |
|
101 iHttpRequest, aStatus ); |
|
102 iHttpResponse->SetInternalError( aError ); |
|
103 iHttpResponse->SetBodyL( aResponseBody ); |
|
104 } |
|
105 |
|
106 |
|
107 //end of file |
|
108 |