applayerpluginsandutils/httpprotocolplugins/httpheadercodec/chttpclientheaderwriter.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 "chttpclientheaderwriter.h"
       
    17 
       
    18 #include <httpstringconstants.h>
       
    19 #include <http/rhttpsession.h>
       
    20 #include <httperr.h>
       
    21 #include <inetprottextutils.h>
       
    22 
       
    23 #include "CHeaderField.h"
       
    24 
       
    25 _LIT8(KSemiSpaceSep,"; ");
       
    26 _LIT8(KCodecSpace, " ");
       
    27 
       
    28 const TInt KMaxNumPortDigits			= 5;
       
    29 const TInt KMaxNumPortValue = 0xffff;	// RFC 793
       
    30 
       
    31 const TInt KNormalAcceptHeaderLen = 96;
       
    32 const TInt KNormalAcceptCharsetHeaderLen = 64;
       
    33 const TInt KNormalAcceptEncodingHeaderLen = 64;
       
    34 const TInt KNormalAcceptLanguageHeaderLen = 64;
       
    35 CHttpClientHeaderWriter* CHttpClientHeaderWriter::NewL(RStringPool aStringPool)
       
    36 /** 
       
    37 	Factory constructor.
       
    38 	@internalComponent
       
    39 	@param		aStringPool	The current string pool.
       
    40 	@return		A pointer to a fully initialised object.
       
    41 	@leave		KErrNoMemory	Not enough memory to create object.
       
    42 */
       
    43 	{
       
    44 	return new (ELeave) CHttpClientHeaderWriter(aStringPool);
       
    45 	}
       
    46 
       
    47 CHttpClientHeaderWriter::~CHttpClientHeaderWriter()
       
    48 /**
       
    49 	Destructor
       
    50 	@internalComponent
       
    51 */
       
    52 	{
       
    53 	}
       
    54 
       
    55 CHttpClientHeaderWriter::CHttpClientHeaderWriter(RStringPool aStringPool)
       
    56 : CHttpHeaderWriter(aStringPool)
       
    57 /**
       
    58 	Constructor
       
    59 	@internalComponent
       
    60 	@param		aStringPool	The current string pool.
       
    61 */	{
       
    62 	}
       
    63 
       
    64 void CHttpClientHeaderWriter::EncodeAcceptL(RHeaderField& aHeader) const
       
    65 /**
       
    66 	Encodes the accept header. RFC2616 section 14.1 - 
       
    67   
       
    68 		Accept			   =	"Accept" ":" #( media-range [ accept-params ] )
       
    69 							
       
    70 		media-range			=	( "*" "/" "*"
       
    71 							|	( type "/" "*" )
       
    72 							|	( type "/" subtype )
       
    73 							)	*( ";" parameter )
       
    74 
       
    75 		accept-params		=	";" "q" "=" qvalue *( accept-extension )
       
    76 		accept-extension	=	";" token [ "=" ( token | quoted-string ) ]
       
    77 
       
    78 	The accept header value is a comma separated list of values that may be
       
    79 	empty.
       
    80 	@internalComponent
       
    81 	@param		aHeader	The accept header field to encode.
       
    82 	@leave		CHttpWriter::DoGeneralAcceptHeaderL
       
    83 	@todo		Is this function needed at all - go straight to DoGeneralAcceptHeaderL?
       
    84 */
       
    85 	{
       
    86 	DoGeneralAcceptHeaderL( KNormalAcceptHeaderLen,
       
    87 						  aHeader, 
       
    88 						  iStringPool.StringF(HTTP::EAccept, iStringTable),
       
    89 						  KErrHttpEncodeAccept
       
    90 						  );
       
    91 	}
       
    92 
       
    93 void CHttpClientHeaderWriter::EncodeAcceptCharsetL(RHeaderField& aHeader) const
       
    94 /**
       
    95 	Encodes the accept-charset header. RFC2616 section 14.2 - 
       
    96 	
       
    97 		Accept-Chartset		=	"Accept-Charset" ":" 1#( ( charset | "*" ) [ ";" "q" "=" qvalue ] )
       
    98 
       
    99 	The accept-charset header value is a comma separated list of values that has
       
   100 	at least one value.
       
   101 	@internalComponent
       
   102 	@param		aHeader	The accept-charset header field to encode.
       
   103 	@leave		CHttpWriter::DoGeneralAcceptHeaderL
       
   104 	@todo		Is this function needed at all - go straight to DoGeneralAcceptHeaderL?
       
   105 */
       
   106 	{
       
   107 	DoGeneralAcceptHeaderL( KNormalAcceptCharsetHeaderLen,
       
   108 						  aHeader,
       
   109 						  iStringPool.StringF(HTTP::EAcceptCharset,iStringTable),
       
   110 						  KErrHttpEncodeAcceptCharset
       
   111 						  );
       
   112 	}
       
   113 
       
   114 void CHttpClientHeaderWriter::EncodeAcceptLanguageL(RHeaderField& aHeader) const
       
   115 /**
       
   116 	Encodes the accept-language header. RFC2616 section 14.4 - 
       
   117 	
       
   118 		Accept-Language		=	"Accept-Language" ":" 1#( language-range [ ";" "q" "=" qvalue ] )
       
   119 
       
   120 		language-range		= ( ( 1*8ALPHA *( "-" 1*8ALPHA ) ) ! "*" )
       
   121 
       
   122 	The accept-language header value is a comma separated list of values that has
       
   123 	at least one value.
       
   124 	@internalComponent
       
   125 	@param		aHeader	The accept-language header field to encode.
       
   126 	@leave		CHttpWriter::DoGeneralAcceptHeaderL
       
   127 	@todo		Is this function needed at all - go straight to DoGeneralAcceptHeaderL?
       
   128 */
       
   129 	{
       
   130 	DoGeneralAcceptHeaderL(KNormalAcceptLanguageHeaderLen,
       
   131 						  aHeader,
       
   132 						  iStringPool.StringF(HTTP::EAcceptLanguage,iStringTable),
       
   133 						  KErrHttpEncodeAcceptLanguage
       
   134 						  );
       
   135 	}
       
   136 
       
   137 void CHttpClientHeaderWriter::EncodeAuthorizationL(RHeaderField& aHeader) const
       
   138 /**
       
   139 	Encodes the authorization header. RFC2616 section 14.4 - 
       
   140 	
       
   141 		Authorization		=	"Authorization" ":" credentials
       
   142 		credentials			=	auth-scheme #auth-param
       
   143 							|	"Digest" digest-response
       
   144 							|	"Basic" basic-credentials
       
   145 
       
   146 		basic-credentials	=	base64-user-pass
       
   147 		base64-user-pass	=	<base64 [4] encoding of user-pass, except not limited to 76 char/line>
       
   148 		user-pass			=	userid ":" password
       
   149 		userid				=	*<TEXT excluding ":">
       
   150 		password			=	*TEXT
       
   151 		
       
   152 		digest-response		=	1#( username | realm | nonce | digest-uri |	response |
       
   153 								[ algorithm ] | [ cnonce ] |
       
   154 								[ opaque ] | [ message-qop ] |
       
   155 								[ nonce-count ] | [ auth-param ] )
       
   156 
       
   157 		username			=	"username" "=" username-value
       
   158 		username-value		=	quoted-string
       
   159 		digest-uri			=	"uri" "=" digest-uri-value
       
   160 		digest-uri-value	=	request-uri ; As specified by HTTP/1.1
       
   161 		message-qop			=	"qop" "=" qop-value
       
   162 		cnonce				=	"cnonce" "=" cnonce-value
       
   163 		cnonce-value		=	nonce-value
       
   164 		nonce-count			=	"nc" "=" nc-value
       
   165 		nc-value			=	8LHEX
       
   166 		response			=	"response" "=" request-digest
       
   167 		request-digest		=	<"> 32LHEX <">
       
   168 		LHEX				=	"0" | "1" | "2" | "3" |
       
   169 								"4" | "5" | "6" | "7" |
       
   170 								"8" | "9" | "a" | "b" |
       
   171 								"c" | "d" | "e" | "f"
       
   172 	
       
   173 	Encoding here is interpreted very simply. Parts are encoded with no 
       
   174 	punctuation after them and parameters are comma separated with the value in
       
   175 	quotes. This means that for basic authentication, part 1 must be 'Basic' and
       
   176 	part 2 is the credentials. For digest, part1 is 'Digest', and the 
       
   177 	digest-response is stored in parameters.
       
   178 	@internalComponent
       
   179 	@param		aHeader	The authorization header field to encode.
       
   180 	@leave		RHeaderField::BeginRawDataL
       
   181 	@leave		RHeaderField::PartsL
       
   182 	@leave		RHeaderField::WriteRawDataL
       
   183 	@leave		KErrHttpEncodeAuthorization	There were no parts, or the part
       
   184 											value type or the parameter value 
       
   185 											type was not a string or a folded 
       
   186 											string.
       
   187 */
       
   188 	{
       
   189 	__START_PERFORMANCE_LOGGER();
       
   190 	// Check part 1
       
   191 	aHeader.BeginRawDataL();
       
   192 	THeaderFieldPartIter iter = aHeader.PartsL();
       
   193 	for( iter.First(); !iter.AtEnd(); )
       
   194 		{
       
   195 		const CHeaderFieldPart* part = iter();
       
   196 		if( part == NULL )
       
   197 			{
       
   198 			// No parts!!
       
   199 			User::Leave(KErrHttpEncodeAuthorization);
       
   200 			}
       
   201 		THTTPHdrVal ptVal = part->Value();
       
   202 		switch( ptVal.Type() )
       
   203 			{
       
   204 		case THTTPHdrVal::KStrFVal:
       
   205 			{
       
   206 			aHeader.WriteRawDataL(ptVal.StrF().DesC());
       
   207 			} break;
       
   208 		case THTTPHdrVal::KStrVal:
       
   209 			{
       
   210 			aHeader.WriteRawDataL(ptVal.Str().DesC());
       
   211 			} break;			
       
   212 		default:
       
   213 			User::Leave(KErrHttpEncodeAuthorization);
       
   214 			break;
       
   215 			}
       
   216 
       
   217 		// Now output the params
       
   218 		THeaderFieldParamIter paramIter = part->Parameters();
       
   219 		for( paramIter.First(); !paramIter.AtEnd(); )
       
   220 			{
       
   221 			const  TInt param = paramIter()->Name().Index(iStringTable);
       
   222 
       
   223 			const TBool quoted = (param != HTTP::ENc && param != HTTP::EAlgorithm  && param != HTTP::EUri  && param != HTTP::EStale);
       
   224 			aHeader.WriteRawDataL(' ');
       
   225 			aHeader.WriteRawDataL(paramIter()->Name().DesC());
       
   226 			aHeader.WriteRawDataL('=');
       
   227 			
       
   228 			if( quoted ) 
       
   229                 {
       
   230                 aHeader.WriteRawDataL('"');
       
   231                 }
       
   232 
       
   233 			THTTPHdrVal paramVal = paramIter()->Value();
       
   234 			switch (paramVal.Type())
       
   235 				{
       
   236 			case THTTPHdrVal::KStrFVal:
       
   237 				{
       
   238 				aHeader.WriteRawDataL(paramVal.StrF().DesC());
       
   239 				} break;				
       
   240 			case THTTPHdrVal::KStrVal:
       
   241 				{
       
   242 				aHeader.WriteRawDataL(paramVal.Str().DesC());
       
   243 				} break;				
       
   244 			default:
       
   245 				User::Leave(KErrHttpEncodeAuthorization);
       
   246 				break;
       
   247 				}
       
   248 			if( quoted )
       
   249 				{
       
   250 				aHeader.WriteRawDataL('"');
       
   251 				}
       
   252 
       
   253 			
       
   254 			++paramIter;
       
   255 			if (!paramIter.AtEnd())
       
   256 				{
       
   257 				// This is not the last param so add a comma
       
   258 				aHeader.WriteRawDataL(',');
       
   259 				}
       
   260 			}
       
   261 		++iter;
       
   262 		if( !iter.AtEnd() )
       
   263 			{
       
   264 			// This is not the last part so add a space.
       
   265 			aHeader.WriteRawDataL(' ');
       
   266 			}
       
   267 		}
       
   268 	aHeader.CommitRawData();
       
   269 	__END_PERFORMANCE_LOGGER(_L(",CHttpClientHeaderWriter::EncodeAuthorizationL()"));
       
   270 	}
       
   271 
       
   272 void CHttpClientHeaderWriter::EncodeHostL(RHeaderField& aHeader) const
       
   273 /**
       
   274 	Encodes the host header. RFC2616 section 14.23
       
   275 
       
   276 		Host			=	"Host" ":" host [ ":" port ]
       
   277 
       
   278 	The host header value may be empty.
       
   279 	@internalComponent
       
   280 	@param		aHeader	The host header field to encode.
       
   281 	@leave		RHeaderField::BeginRawDataL
       
   282 	@leave		RHeaderField::PartsL
       
   283 	@leave		RHeaderField::WriteRawDataL
       
   284 	@leave		KErrHttpEncodeHost	There were no parts, or the part value type
       
   285 									or the parameter value type was not a string
       
   286 									or a folded string.
       
   287 */
       
   288 	{
       
   289 	__START_PERFORMANCE_LOGGER();
       
   290 	// Our convention will be that a string called HTTP::EPort will be used to
       
   291 	// set a parameter holding the integer port number
       
   292 	// Check part 1
       
   293 	THeaderFieldPartIter iter1 = aHeader.PartsL();
       
   294 	iter1.First();
       
   295 	if( iter1.AtEnd() )
       
   296 		{
       
   297 		User::Leave(KErrHttpEncodeHost);
       
   298 		}
       
   299 	const CHeaderFieldPart* part = iter1();
       
   300 	if( part == NULL)
       
   301 		{
       
   302 		User::Leave(KErrHttpEncodeHost);
       
   303 		}
       
   304 	THTTPHdrVal pt1val = part->Value();
       
   305 	if( pt1val.Type() != THTTPHdrVal::KStrFVal )
       
   306 		{
       
   307 		User::Leave(KErrHttpEncodeHost);
       
   308 		}
       
   309 	// Write the host string
       
   310 	RStringF hostStr = pt1val.StrF();
       
   311 	aHeader.BeginRawDataL();
       
   312 	aHeader.WriteRawDataL(hostStr.DesC());
       
   313 
       
   314 	// Check for a port number
       
   315 	THeaderFieldParamIter iter2 = part->Parameters();
       
   316 	iter2.First();
       
   317 	if( !iter2.AtEnd() )
       
   318 		{
       
   319 		// Got a parameter - if its the port, check then write it
       
   320 		const CHeaderFieldParam* param = iter2();
       
   321 		if( !param )
       
   322 			{
       
   323 			User::Leave(KErrHttpEncodeHostPort);
       
   324 			}
       
   325 		if( param->Name() == iStringPool.StringF(HTTP::EPort,iStringTable) )
       
   326 			{
       
   327 			// Get the port value
       
   328 			THTTPHdrVal portVal = param->Value();
       
   329 			if (portVal.Type() != THTTPHdrVal::KTIntVal)
       
   330 				{
       
   331 				User::Leave(KErrHttpEncodeHostPort);
       
   332 				}
       
   333 			TBuf8<KMaxNumPortDigits> portDesC;
       
   334 			const TInt portValue = portVal.Int();
       
   335 			if(portValue > KMaxNumPortValue) 
       
   336 				{
       
   337 				User::Leave(KErrHttpEncodeHostPort);
       
   338 				}
       
   339 			portDesC.Num(portValue);
       
   340 			aHeader.WriteRawDataL(':');
       
   341 			aHeader.WriteRawDataL(portDesC);
       
   342 			}
       
   343 		}
       
   344 	aHeader.CommitRawData();
       
   345 	__END_PERFORMANCE_LOGGER(_L(",CHttpClientHeaderWriter::EncodeHostL()"));
       
   346 	}
       
   347 
       
   348 void CHttpClientHeaderWriter::EncodeTEL(RHeaderField& aHeader) const
       
   349 /**
       
   350 	Encode the TE header. RFC2616 section 14.39.
       
   351 
       
   352 		TE			=	"TE" ":" #( t-codings )
       
   353 		t-codings	=	"trailers" | ( transfer-extension [ accept-params ] )
       
   354 	The TE header field value is comma separated list that may be empty.
       
   355 	@internalComponent
       
   356 	@param		aHeader	The host header field to encode.
       
   357 	@leave		CHttpWriter::DoGeneralAcceptHeaderL
       
   358 */
       
   359 	{       
       
   360 	DoGeneralAcceptHeaderL(KHttpDefaultRawChunkSize, aHeader, iStringPool.StringF(HTTP::ETE,iStringTable), KErrHttpEncodeTE);
       
   361 	}
       
   362 
       
   363 void CHttpClientHeaderWriter::EncodeUserAgentL(RHeaderField& aHeader) const
       
   364 	{
       
   365 	// User-Agent     = "User-Agent" ":" 1*( product | comment )
       
   366 	//  Example: User-Agent: CERN-LineMode/2.15 libwww/2.17b3
       
   367 	DoTokenListHeaderL(aHeader, KCodecSpace, KErrHttpEncodeUserAgent);
       
   368 	}
       
   369 
       
   370 void CHttpClientHeaderWriter::EncodeCookieL(RHeaderField& aHeader) const
       
   371 	{
       
   372 		__START_PERFORMANCE_LOGGER();
       
   373 	// NETSCAPE Persistent Client State HTTP Cookies (http://www.netscape.com/newsref/std/cookie_spec.html)
       
   374 	// Cookie Header Line = "Cookie: " 1*COOKIE
       
   375 	// COOKIE = NAME=VALUE
       
   376 
       
   377 	// RFC 2965 HTTP State Management Mechanism
       
   378 	// cookie = "Cookie" cookie-version 1* ((";" | ",") cookie-value)
       
   379 	// cookie-value = NAME "=" VALUE [";" path] [";" domain] [";" port]
       
   380 	// NAME = attr
       
   381 	// VALUE = value
       
   382 	// path = "$Path" "=" value
       
   383 	// domain = "$Domain" "=" value
       
   384 	// port = "$Port" ["=" <"> value <">]
       
   385 	
       
   386 
       
   387 	// cookies are stored internally as parts in a header (the cookie header);
       
   388 	// each header part has a number of parameters which indicate parts of the cookie header. Netscape style cookies do not have
       
   389 	// a version parameter. If we get a netscape style cookie then only the name and value get written out.
       
   390 
       
   391 	// Otherwise the cookie will be either a RFC 2109 or RFC 2965 style cookie which can be treated identically
       
   392 	
       
   393 	THeaderFieldPartIter iter = aHeader.PartsL();
       
   394 	iter.First();
       
   395 	if (iter.AtEnd())
       
   396 		User::Leave(KErrHttpEncodeCookie);
       
   397 
       
   398 	TBool usingNetscapeStyleCookies = ETrue;
       
   399 	TBool setVersion = EFalse;
       
   400 	
       
   401 	aHeader.BeginRawDataL();
       
   402 	while(!iter.AtEnd())
       
   403 		{
       
   404 		// Write out one cookie
       
   405 		const CHeaderFieldPart* part = iter();
       
   406 		if (part == NULL)
       
   407 			User::Leave(KErrHttpEncodeCookie);
       
   408 		
       
   409 		if (!setVersion)
       
   410 			{
       
   411 			setVersion = ETrue;
       
   412 			RStringF version = iStringPool.StringF(HTTP::EVersion,iStringTable);
       
   413 			THeaderFieldParamIter paramIter = part->Parameters();
       
   414 			paramIter.First();
       
   415 			while (!paramIter.AtEnd())
       
   416 				{
       
   417 				const CHeaderFieldParam* param = paramIter();
       
   418 				if (param->Name() == version)
       
   419 					{
       
   420 					usingNetscapeStyleCookies = EFalse;
       
   421 					EncodeOneCookieAttributeL(aHeader, *param);
       
   422 					aHeader.WriteRawDataL(KSemiSpaceSep);
       
   423 					break;
       
   424 					}
       
   425 				++paramIter;
       
   426 				}
       
   427 			}
       
   428 		EncodeOneCookieL(aHeader, *part, usingNetscapeStyleCookies);
       
   429 
       
   430 		++iter;
       
   431 		if (!iter.AtEnd())
       
   432 			aHeader.WriteRawDataL(KSemiSpaceSep);
       
   433 		}
       
   434 	aHeader.CommitRawData();
       
   435 	__END_PERFORMANCE_LOGGER(_L(",CHttpClientHeaderWriter::EncodeCookieL()"));
       
   436 	}
       
   437 
       
   438 
       
   439 void CHttpClientHeaderWriter::EncodeOneCookieAttributeL(RHeaderField& aHeader, const CHeaderFieldParam& aAttribute) const
       
   440 	{
       
   441 	const TBool quoted = ( aAttribute.Name().Index(iStringTable) == HTTP::ECookiePort );
       
   442 	aHeader.WriteRawDataL( '$' );
       
   443 	aHeader.WriteRawDataL( aAttribute.Name().DesC() );
       
   444 	aHeader.WriteRawDataL( '=' );
       
   445 	if( quoted )
       
   446 		{
       
   447 		aHeader.WriteRawDataL( '"' );
       
   448 		}
       
   449 	aHeader.WriteRawDataL( aAttribute.Value().StrF().DesC() );
       
   450 	if( quoted )
       
   451 		{
       
   452 		aHeader.WriteRawDataL( '"' );
       
   453 		}
       
   454 	}
       
   455 
       
   456 void CHttpClientHeaderWriter::EncodeOneCookieL(RHeaderField& aHeader, const CHeaderFieldPart& aCookieFieldPart, TBool aIsNetscapeStyleCookie) const
       
   457 	{
       
   458 	// Always write out the name and value attributes which should come first and second. Only write out the other attributes 
       
   459 	// if they are one of Path, Domain, Port
       
   460 
       
   461 	THeaderFieldParamIter paramIter = aCookieFieldPart.Parameters();
       
   462 	paramIter.First();
       
   463 
       
   464 	TBool separatorNeeded = EFalse;
       
   465 	while( !paramIter.AtEnd() )
       
   466 		{
       
   467 		const CHeaderFieldParam* param = paramIter();
       
   468 
       
   469 		switch( param->Name().Index(iStringTable) )
       
   470 			{
       
   471 		case HTTP::EDomain:
       
   472 		case HTTP::EPath:
       
   473 		case HTTP::ECookiePort:
       
   474 			{
       
   475 			if( !aIsNetscapeStyleCookie )
       
   476 				{
       
   477 				aHeader.WriteRawDataL(KSemiSpaceSep);
       
   478 				EncodeOneCookieAttributeL(aHeader, *param);
       
   479 				}
       
   480 			} break;
       
   481 		case HTTP::ECookieName:
       
   482 			{
       
   483 			if( separatorNeeded )
       
   484 				aHeader.WriteRawDataL(KSemiSpaceSep);
       
   485 			aHeader.WriteRawDataL(param->Value().Str().DesC());
       
   486 			} break;
       
   487 		case HTTP::ECookieValue:
       
   488 			{
       
   489 			aHeader.WriteRawDataL('=');
       
   490 			aHeader.WriteRawDataL(param->Value().Str().DesC());
       
   491 			separatorNeeded = ETrue;
       
   492 			} break;
       
   493 		default:
       
   494 			break;
       
   495 			}
       
   496 		++paramIter;
       
   497 		}
       
   498 	}
       
   499 
       
   500 		
       
   501 /*
       
   502  *	Methods from CHeaderWriter
       
   503  */
       
   504 
       
   505 void CHttpClientHeaderWriter::EncodeHeaderL(RHeaderField& aHeader)
       
   506 	{
       
   507 	RStringF fieldStr = iStringPool.StringF(aHeader.Name());
       
   508 	switch( fieldStr.Index(iStringTable) )
       
   509 		{
       
   510 	case HTTP::EAccept:
       
   511 		{
       
   512 		EncodeAcceptL(aHeader);
       
   513 		} break;
       
   514 	case HTTP::EAcceptCharset:
       
   515 		{
       
   516 		EncodeAcceptCharsetL(aHeader);
       
   517 		} break;
       
   518 	case HTTP::EAuthorization:
       
   519 		{
       
   520 		EncodeAuthorizationL(aHeader);
       
   521 		} break;
       
   522 	case HTTP::EAcceptLanguage:
       
   523 		{
       
   524 		EncodeAcceptLanguageL(aHeader);
       
   525 		} break;
       
   526 	case HTTP::EAcceptEncoding:
       
   527 		{
       
   528 		DoGeneralAcceptHeaderL(KNormalAcceptEncodingHeaderLen, aHeader, iStringPool.StringF(HTTP::EAcceptEncoding,iStringTable), KErrHttpEncodeAcceptEncoding);
       
   529 		} break;
       
   530 	case HTTP::EHost:
       
   531 		{
       
   532 		EncodeHostL(aHeader);
       
   533 		} break;
       
   534 	case HTTP::EUserAgent:
       
   535 		{
       
   536 		EncodeUserAgentL(aHeader);
       
   537 		} break;
       
   538 	case HTTP::ECookie:
       
   539 		{
       
   540 		EncodeCookieL(aHeader);
       
   541 		} break;
       
   542 	case HTTP::EIfMatch:
       
   543 		{
       
   544 		DoTokenCsvListHeaderL(aHeader, KErrHttpEncodeIfMatch);
       
   545 		} break;
       
   546 	case HTTP::EIfNoneMatch:
       
   547 		{
       
   548 		DoTokenCsvListHeaderL(aHeader, KErrHttpEncodeIfMatch);
       
   549 		} break;
       
   550 	case HTTP::EIfModifiedSince:
       
   551 		{
       
   552 		EncodeGenericDateL(aHeader, KErrHttpEncodeIfModifiedSince);
       
   553 		} break;
       
   554 	case HTTP::EIfUnmodifiedSince:
       
   555 		{
       
   556 		EncodeGenericDateL(aHeader, KErrHttpEncodeIfUnmodifiedSince);
       
   557 		} break;
       
   558 	case HTTP::ECookie2:
       
   559 		{
       
   560 		EncodeGenericNumberHeaderL(aHeader, KErrHttpEncodeCookie2);
       
   561 		} break;
       
   562 	case HTTP::ETE:
       
   563 		{
       
   564 		EncodeTEL(aHeader);
       
   565 		} break;
       
   566 	default:
       
   567 		User::Leave(KErrNotSupported);
       
   568 		break;
       
   569 		}
       
   570 	}