applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp
branchRCL_3
changeset 18 5f1cd966e0d9
parent 7 2611c08ee28e
child 19 c0c2f28ace9c
--- a/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp	Thu Jul 15 19:14:59 2010 +0300
+++ b/applayerpluginsandutils/httpprotocolplugins/httpclient/chttpresponseparser.cpp	Thu Aug 19 10:27:19 2010 +0300
@@ -27,6 +27,7 @@
 #include "mhttpresponseobserver.h"
 #include "thttpclientpanic.h"
 #include "chttpconnectioninfo.h"
+#include <e32math.h>
 
 _LIT8(KHeaderSeparator,	"\n");
 
@@ -295,9 +296,15 @@
 			
 			}
 		else
-	        {
-			// Need to map to appropriate error code if the disconnect notification is
-			// asked by the client
+	        {		    
+            // Check client has asked to return Default Error occured while Disconnect received
+            if (clientTrans->PropogateDefaultError())
+               {
+               NotifyObserverError(aError);             
+               return;
+               }
+            // Need to map to appropriate error code if the disconnect notification is
+            // asked by the client			
 			if ( clientTrans->NeedDisconnectNotification() )
 				{
 				CHttpRequestComposer& request = static_cast<CHttpRequestComposer&>(iProtTrans->TxData());
@@ -498,6 +505,40 @@
                  }
 		}
 		
+ 		if (name.DesC().CompareF(stringPool.StringF(HTTP::EWWWAuthenticate,RHTTPSession::GetTable()).DesC()) == KErrNone)
+            {
+            _LIT8(KNtlmProtocolName,"NTLM");
+            if (aFieldValue.FindF(KNtlmProtocolName)!= KErrNotFound)
+                {
+                CHttpClientTransaction& protTran = static_cast<CHttpClientTransaction&>(*iProtTrans);
+                CHttpConnectionManager* manager = protTran.ConnectionManager();
+                _LIT8( KNtlmConnId, "NTLMConnId" );
+                if (aFieldValue.Length() >=  4 )
+                    {
+                    if (manager->GetNtlmConnId() == KErrNotFound)
+                        {
+                        TInt ntmlConnId= Math::Random()%5789; //some magic number to get random connection  id
+                        manager->SetNtlmConnId(ntmlConnId);
+                        RStringF ntlmId= stringPool.OpenFStringL( KNtlmConnId );
+                        CleanupClosePushL(ntlmId);
+                        THTTPHdrVal value;
+                        value.SetInt( ntmlConnId );
+                        trans.PropertySet().SetPropertyL( ntlmId, value );
+                        CleanupStack::PopAndDestroy(&ntlmId);
+                        }
+                    else
+                        {
+                        RStringF ntlmId= stringPool.OpenFStringL( KNtlmConnId );
+                        CleanupClosePushL(ntlmId);
+                        THTTPHdrVal value;
+                        value.SetInt(manager->GetNtlmConnId());
+                        trans.PropertySet().SetPropertyL( ntlmId, value );    
+                        CleanupStack::PopAndDestroy(&ntlmId);
+                        }
+                    }
+               }
+            }
+ 		
 		CleanupStack::PopAndDestroy(&name);
 		
 		if( BodyComplete() && !GotTrailers() )	
@@ -767,9 +808,11 @@
 TBool CHttpResponseParser::NeedCompletion ()
 	{
 	RHTTPTransaction trans = iProtTrans->Transaction ();
-	if ( HTTPStatus::IsRedirection ( trans.Response().StatusCode() ) )
+	TInt statusCode = trans.Response().StatusCode();
+	if ( HTTPStatus::IsRedirection ( statusCode )|| statusCode == HTTPStatus::EUnauthorized )
 		{
 		// If it is a redirection message then we need to complete the response
+		// for 401 error..we have to continue on the same port..so we need to complete the response immediately
 		return ETrue;			
 		}
 	return EFalse;