applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp
branchRCL_3
changeset 18 5f1cd966e0d9
parent 7 2611c08ee28e
child 19 c0c2f28ace9c
equal deleted inserted replaced
17:a2a70ce3d4e8 18:5f1cd966e0d9
    25 #include "chttpconnectionmanager.h"
    25 #include "chttpconnectionmanager.h"
    26 #include "chttprequestcomposer.h"
    26 #include "chttprequestcomposer.h"
    27 #include "mhttpresponseobserver.h"
    27 #include "mhttpresponseobserver.h"
    28 #include "thttpclientpanic.h"
    28 #include "thttpclientpanic.h"
    29 #include "chttpconnectioninfo.h"
    29 #include "chttpconnectioninfo.h"
       
    30 #include <e32math.h>
    30 
    31 
    31 _LIT8(KHeaderSeparator,	"\n");
    32 _LIT8(KHeaderSeparator,	"\n");
    32 
    33 
    33 CHttpResponseParser* CHttpResponseParser::NewL(CProtTransaction& aProtTrans, MRxDataObserver& aObserver, MHttpResponseObserver& aResponseObserver)
    34 CHttpResponseParser* CHttpResponseParser::NewL(CProtTransaction& aProtTrans, MRxDataObserver& aObserver, MHttpResponseObserver& aResponseObserver)
    34 	{
    35 	{
   293 					}
   294 					}
   294 				}
   295 				}
   295 			
   296 			
   296 			}
   297 			}
   297 		else
   298 		else
   298 	        {
   299 	        {		    
   299 			// Need to map to appropriate error code if the disconnect notification is
   300             // Check client has asked to return Default Error occured while Disconnect received
   300 			// asked by the client
   301             if (clientTrans->PropogateDefaultError())
       
   302                {
       
   303                NotifyObserverError(aError);             
       
   304                return;
       
   305                }
       
   306             // Need to map to appropriate error code if the disconnect notification is
       
   307             // asked by the client			
   301 			if ( clientTrans->NeedDisconnectNotification() )
   308 			if ( clientTrans->NeedDisconnectNotification() )
   302 				{
   309 				{
   303 				CHttpRequestComposer& request = static_cast<CHttpRequestComposer&>(iProtTrans->TxData());
   310 				CHttpRequestComposer& request = static_cast<CHttpRequestComposer&>(iProtTrans->TxData());
   304 				// if we are consuming response then the request has been not sent fully.
   311 				// if we are consuming response then the request has been not sent fully.
   305 				if ( ConsumingResponse () || !request.RequestSent() )
   312 				if ( ConsumingResponse () || !request.RequestSent() )
   496                  #endif
   503                  #endif
   497                  manager->AppendPipelineFailedHost(hostVal.StrF().DesC());
   504                  manager->AppendPipelineFailedHost(hostVal.StrF().DesC());
   498                  }
   505                  }
   499 		}
   506 		}
   500 		
   507 		
       
   508  		if (name.DesC().CompareF(stringPool.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable()).DesC()) == KErrNone)
       
   509             {
       
   510             _LIT8(KNtlmProtocolName,"NTLM");
       
   511             if (aFieldValue.FindF(KNtlmProtocolName)!= KErrNotFound)
       
   512                 {
       
   513                 CHttpClientTransaction& protTran = static_cast<CHttpClientTransaction&>(*iProtTrans);
       
   514                 CHttpConnectionManager* manager = protTran.ConnectionManager();
       
   515                 _LIT8( KNtlmConnId, "NTLMConnId" );
       
   516                 if (aFieldValue.Length() >=  4 )
       
   517                     {
       
   518                     if (manager->GetNtlmConnId() == KErrNotFound)
       
   519                         {
       
   520                         TInt ntmlConnId= Math::Random()%5789; //some magic number to get random connection  id
       
   521                         manager->SetNtlmConnId(ntmlConnId);
       
   522                         RStringF ntlmId= stringPool.OpenFStringL( KNtlmConnId );
       
   523                         CleanupClosePushL(ntlmId);
       
   524                         THTTPHdrVal value;
       
   525                         value.SetInt( ntmlConnId );
       
   526                         trans.PropertySet().SetPropertyL( ntlmId, value );
       
   527                         CleanupStack::PopAndDestroy(&ntlmId);
       
   528                         }
       
   529                     else
       
   530                         {
       
   531                         RStringF ntlmId= stringPool.OpenFStringL( KNtlmConnId );
       
   532                         CleanupClosePushL(ntlmId);
       
   533                         THTTPHdrVal value;
       
   534                         value.SetInt(manager->GetNtlmConnId());
       
   535                         trans.PropertySet().SetPropertyL( ntlmId, value );    
       
   536                         CleanupStack::PopAndDestroy(&ntlmId);
       
   537                         }
       
   538                     }
       
   539                }
       
   540             }
       
   541  		
   501 		CleanupStack::PopAndDestroy(&name);
   542 		CleanupStack::PopAndDestroy(&name);
   502 		
   543 		
   503 		if( BodyComplete() && !GotTrailers() )	
   544 		if( BodyComplete() && !GotTrailers() )	
   504 			{
   545 			{
   505 			// This was a trailer header - flag that there are trailers.
   546 			// This was a trailer header - flag that there are trailers.
   765 	}
   806 	}
   766 
   807 
   767 TBool CHttpResponseParser::NeedCompletion ()
   808 TBool CHttpResponseParser::NeedCompletion ()
   768 	{
   809 	{
   769 	RHTTPTransaction trans = iProtTrans->Transaction ();
   810 	RHTTPTransaction trans = iProtTrans->Transaction ();
   770 	if ( HTTPStatus::IsRedirection ( trans.Response().StatusCode() ) )
   811 	TInt statusCode = trans.Response().StatusCode();
       
   812 	if ( HTTPStatus::IsRedirection ( statusCode )|| statusCode == HTTPStatus::EUnauthorized )
   771 		{
   813 		{
   772 		// If it is a redirection message then we need to complete the response
   814 		// If it is a redirection message then we need to complete the response
       
   815 		// for 401 error..we have to continue on the same port..so we need to complete the response immediately
   773 		return ETrue;			
   816 		return ETrue;			
   774 		}
   817 		}
   775 	return EFalse;		
   818 	return EFalse;		
   776 	}
   819 	}
   777 
   820