applayerpluginsandutils/httpprotocolplugins/httpheadercodec/chttpgeneralheadercodec.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     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 "chttpgeneralheadercodec.h"
       
    17 
       
    18 #include <http/rhttpsession.h>
       
    19 #include <httpstringconstants.h>
       
    20 
       
    21 #include "chttpdefaultheadercodec.h"
       
    22 #include "chttpgeneralheaderwriter.h"
       
    23 #include "chttpgeneralheaderreader.h"
       
    24 
       
    25 CHttpGeneralHeaderCodec* CHttpGeneralHeaderCodec::NewL(TAny* aStringPool)
       
    26 /** 
       
    27 	Factory constructor.
       
    28 	@internalComponent
       
    29 	@param		aStringPool	The current string pool.
       
    30 	@return		A pointer to a fully initialised object.
       
    31 	@leave		KErrNoMemory	Not enough memory to create object.
       
    32 	@leave		CHttpGeneralHeaderCodec::ConstructL
       
    33 */
       
    34 	{
       
    35 	RStringPool* strPool = static_cast<RStringPool*>(aStringPool);
       
    36 	CHttpGeneralHeaderCodec* self = new (ELeave) CHttpGeneralHeaderCodec(*strPool);
       
    37 	CleanupStack::PushL(self);
       
    38 	self->ConstructL();
       
    39 	CleanupStack::Pop(self);
       
    40 	return self;
       
    41 	}
       
    42 
       
    43 CHttpGeneralHeaderCodec::~CHttpGeneralHeaderCodec()
       
    44 /**	
       
    45 	Destructor.
       
    46 	@internalComponent
       
    47 */
       
    48 	{
       
    49 	}
       
    50 
       
    51 CHttpGeneralHeaderCodec::CHttpGeneralHeaderCodec(RStringPool aStringPool)
       
    52 : CHeaderCodecPlugin(), iStringPool(aStringPool), iStringTable(RHTTPSession::GetTable())
       
    53 /**
       
    54 	Constructor
       
    55 	@internalComponent
       
    56 	@param		aStringPool	The current string pool.
       
    57 */
       
    58 	{
       
    59 	}
       
    60 
       
    61 void CHttpGeneralHeaderCodec::ConstructL()
       
    62 /**
       
    63 	Second phase constructor
       
    64 	@internalComponent
       
    65 	@leave		CHeaderCodec::ConstructL
       
    66 	@leave		CHttpGeneralHeaderWriter::NewL
       
    67 	@leave		CHttpGeneralHeaderReader::NewL
       
    68 */
       
    69 	{
       
    70 	// Do second phase construction of the base class
       
    71 	CHeaderCodec::ConstructL();
       
    72 
       
    73 	// Create the header writer and reader objects on behalf of the base class
       
    74 	iWriter = CHttpGeneralHeaderWriter::NewL(iStringPool);
       
    75 	iReader = CHttpGeneralHeaderReader::NewL(iStringPool);
       
    76 	}
       
    77 
       
    78 /*
       
    79  *	Methods from CHeaderCodec
       
    80  */
       
    81 
       
    82 TBool CHttpGeneralHeaderCodec::CanEncode(RStringF aHeaderField) const
       
    83 /**
       
    84 	Asks if the codec can encode the specified header. The default codec can 
       
    85 	encode all headers.
       
    86 	@internalComponent
       
    87 	@param		aHeaderField	The header to be encoded.
       
    88 	@return		A value of ETrue if the codec can encode the header or a value 
       
    89 				of EFalse if not.
       
    90 */
       
    91 	{
       
    92 	TBool encode = EFalse;
       
    93 	switch( aHeaderField.Index(iStringTable) )
       
    94 		{
       
    95 	case HTTP::ECacheControl:
       
    96 	case HTTP::EConnection:
       
    97 	case HTTP::EDate:
       
    98 	case HTTP::EPragma:
       
    99 	case HTTP::ETransferEncoding:
       
   100 	case HTTP::EContentEncoding:
       
   101 	case HTTP::EContentLanguage:
       
   102 	case HTTP::EContentLength:
       
   103 	case HTTP::EContentLocation:
       
   104 	case HTTP::EContentMD5:
       
   105 	case HTTP::EContentType:
       
   106 	case HTTP::EContentDisposition:
       
   107 	case HTTP::EExpires:
       
   108 	case HTTP::ELastModified:
       
   109 	case HTTP::EUpgrade:
       
   110 		{
       
   111 		// Can encode these headers
       
   112 		encode = ETrue;
       
   113 		} break;
       
   114 	default:
       
   115 		// Return default value
       
   116 		break;
       
   117 		}
       
   118 	return encode;
       
   119 	}
       
   120 
       
   121 TBool CHttpGeneralHeaderCodec::CanDecode(RStringF aHeaderField) const
       
   122 /**
       
   123 	Asks if the codec can decode the specified header. The default codec can 
       
   124 	decode all headers.
       
   125 	@internalComponent
       
   126 	@param		aHeaderField	The header to be decoded.
       
   127 	@return		A value of ETrue if the codec can decode the header or a value 
       
   128 				of EFalse if not.
       
   129 */
       
   130 	{
       
   131 	return CanEncode(aHeaderField);
       
   132 	}
       
   133 
       
   134 CHeaderCodec* CHttpGeneralHeaderCodec::FindDelegateCodecL(RStringF /*aHeaderField*/) const
       
   135 /**
       
   136 	Asks the codec to find a delegate codec that can deal with the header field.
       
   137 	The http default codec is the final codec that can be used.
       
   138 	@internalComponent
       
   139 	@param		aHeaderField	The header field to be handled.
       
   140 	@return		A pointer to the http default codec.
       
   141 	@leave		CHttpDefaultHeaderCodec::NewL
       
   142 */
       
   143 	{
       
   144 	return CHeaderCodecPlugin::CreateDelegateCodecL(iStringPool);
       
   145 	}