|
1 // Copyright (c) 2002-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 "chttpclientheadercodec.h" |
|
17 |
|
18 #include <http/rhttpsession.h> |
|
19 #include <httpstringconstants.h> |
|
20 |
|
21 #include "chttpclientheaderreader.h" |
|
22 #include "chttpclientheaderwriter.h" |
|
23 #include "chttpgeneralheadercodec.h" |
|
24 |
|
25 CHttpClientHeaderCodec* CHttpClientHeaderCodec::NewL(TAny* aStringPool) |
|
26 { |
|
27 RStringPool* strPool = static_cast<RStringPool*>(aStringPool); |
|
28 CHttpClientHeaderCodec* self = new (ELeave) CHttpClientHeaderCodec(*strPool); |
|
29 CleanupStack::PushL(self); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CHttpClientHeaderCodec::~CHttpClientHeaderCodec() |
|
36 { |
|
37 } |
|
38 |
|
39 CHttpClientHeaderCodec::CHttpClientHeaderCodec(RStringPool aStringPool) |
|
40 : CHeaderCodecPlugin(), iStringPool(aStringPool), |
|
41 iStringTable(RHTTPSession::GetTable()) |
|
42 { |
|
43 } |
|
44 |
|
45 void CHttpClientHeaderCodec::ConstructL() |
|
46 { |
|
47 // Do second phase construction of the base class. |
|
48 CHeaderCodec::ConstructL(); |
|
49 |
|
50 // Create the header writer and reader objects on behalf of the base class |
|
51 iWriter = CHttpClientHeaderWriter::NewL(iStringPool); |
|
52 iReader = CHttpClientHeaderReader::NewL(iStringPool); |
|
53 } |
|
54 |
|
55 /* |
|
56 * Methods from CHeaderCodec |
|
57 */ |
|
58 |
|
59 TBool CHttpClientHeaderCodec::CanEncode(RStringF aHeaderField) const |
|
60 { |
|
61 TBool encode = EFalse; |
|
62 switch( aHeaderField.Index(iStringTable) ) |
|
63 { |
|
64 case HTTP::EAccept: |
|
65 case HTTP::EAcceptCharset: |
|
66 case HTTP::EAcceptLanguage: |
|
67 case HTTP::EAuthorization: |
|
68 case HTTP::EHost: |
|
69 case HTTP::EUserAgent: |
|
70 case HTTP::ECookie: |
|
71 case HTTP::EIfMatch: |
|
72 case HTTP::EIfNoneMatch: |
|
73 case HTTP::EIfModifiedSince: |
|
74 case HTTP::EIfUnmodifiedSince: |
|
75 case HTTP::ECookie2: |
|
76 case HTTP::ETE: |
|
77 { |
|
78 encode = ETrue; |
|
79 } break; |
|
80 default: |
|
81 // Return default value |
|
82 break; |
|
83 } |
|
84 return encode; |
|
85 } |
|
86 |
|
87 TBool CHttpClientHeaderCodec::CanDecode(RStringF aHeaderField) const |
|
88 { |
|
89 TBool decode = EFalse; |
|
90 switch( aHeaderField.Index(iStringTable) ) |
|
91 { |
|
92 case HTTP::ELastModified: |
|
93 case HTTP::EWWWAuthenticate: |
|
94 case HTTP::ESetCookie: |
|
95 case HTTP::ESetCookie2: |
|
96 case HTTP::EAge: |
|
97 case HTTP::EVary: |
|
98 case HTTP::EContentLanguage: |
|
99 case HTTP::EUpgrade: |
|
100 { |
|
101 decode = ETrue; |
|
102 } break; |
|
103 default: |
|
104 // Return default value |
|
105 break; |
|
106 } |
|
107 return decode; |
|
108 } |
|
109 |
|
110 CHeaderCodec* CHttpClientHeaderCodec::FindDelegateCodecL(RStringF /*aHeaderField*/) const |
|
111 { |
|
112 return CHeaderCodecPlugin::CreateDelegateCodecL(iStringPool); |
|
113 } |