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