hotspotfw/internetconnectivitytestservice/src/ictshttphandler.cpp
branchRCL_3
changeset 15 dff6ebfd236f
parent 0 56b72877c1cb
child 32 5bbf13e885a0
equal deleted inserted replaced
8:c2bc3f8c7777 15:dff6ebfd236f
    88 // ---------------------------------------------------------------------------
    88 // ---------------------------------------------------------------------------
    89 //
    89 //
    90 CIctsHttpHandler::~CIctsHttpHandler()
    90 CIctsHttpHandler::~CIctsHttpHandler()
    91     {
    91     {
    92     DEBUG("CIctsHttpHandler::~CIctsHttpHandler()");
    92     DEBUG("CIctsHttpHandler::~CIctsHttpHandler()");
       
    93     RHTTPTransaction notActive;
       
    94     if ( iHttpTransaction != notActive )
       
    95         {
       
    96         iHttpTransaction.Close();
       
    97         }
    93     iHttpSession.Close();
    98     iHttpSession.Close();
    94     CTimer::Cancel();
    99     CTimer::Cancel();
    95     iConnection.Close();
   100     iConnection.Close();
    96     iSocketServ.Close();
   101     iSocketServ.Close();
    97     DEBUG("CIctsHttpHandler::~CIctsHttpHandler() Done");
   102     DEBUG("CIctsHttpHandler::~CIctsHttpHandler() Done");
   241 //    
   246 //    
   242 void CIctsHttpHandler::CancelHttpRequestL()
   247 void CIctsHttpHandler::CancelHttpRequestL()
   243     {
   248     {
   244     DEBUG("CIctsHttpHandler::CancelHttpRequestL()");
   249     DEBUG("CIctsHttpHandler::CancelHttpRequestL()");
   245     CTimer::Cancel();
   250     CTimer::Cancel();
   246     iHttpTransaction.Cancel();
   251     RHTTPTransaction notActive;
       
   252     if ( iHttpTransaction != notActive )
       
   253         {
       
   254         iHttpTransaction.Close();
       
   255         }
   247     }
   256     }
   248 
   257 
   249 // ---------------------------------------------------------------------------
   258 // ---------------------------------------------------------------------------
   250 // CIctsHttpHandler::RunL
   259 // CIctsHttpHandler::RunL
   251 // ---------------------------------------------------------------------------
   260 // ---------------------------------------------------------------------------
   252 //
   261 //
   253 void CIctsHttpHandler::RunL()
   262 void CIctsHttpHandler::RunL()
   254     {
   263     {
   255     DEBUG("CIctsHttpHandler::RunL()");
   264     DEBUG("CIctsHttpHandler::RunL()");
   256     iHttpSession.Close();
   265     RHTTPTransaction notActive;
       
   266     if ( iHttpTransaction != notActive )
       
   267         {
       
   268         iHttpTransaction.Close();
       
   269         }
   257     iString = KNullDesC;
   270     iString = KNullDesC;
   258     iOwner.HttpEventL( ETimeout, iString );
   271     iOwner.HttpEventL( ETimeout, iString );
   259     }
   272     }
   260 
   273 
   261 
   274 
   294         
   307         
   295         case THTTPEvent::ESucceeded:
   308         case THTTPEvent::ESucceeded:
   296             {
   309             {
   297             DEBUG("CIctsHttpHandler::THTTPEvent::ESucceeded");
   310             DEBUG("CIctsHttpHandler::THTTPEvent::ESucceeded");
   298             CTimer::Cancel();
   311             CTimer::Cancel();
   299             // Indicates that transaction succeeded. 
       
   300             // Transaction can be closed now. It's not needed anymore.
       
   301             aTransaction.Close();
       
   302             iHttpSession.Close();
       
   303             iOwner.HttpEventL( EConnectionOk, iString );
   312             iOwner.HttpEventL( EConnectionOk, iString );
   304             iString = KNullDesC;
   313             iString = KNullDesC;
   305             }
   314             }
   306             break;
   315             break;
   307 
   316 
   330                    DEBUG("CIctsHttpHandler::THTTPEvent::GetField");
   339                    DEBUG("CIctsHttpHandler::THTTPEvent::GetField");
   331                     // Location header is present
   340                     // Location header is present
   332                     RStringF fieldValStr = strP.StringF(hVal.StrF());
   341                     RStringF fieldValStr = strP.StringF(hVal.StrF());
   333                     const TDesC8& fieldValDesC = fieldValStr.DesC();
   342                     const TDesC8& fieldValDesC = fieldValStr.DesC();
   334                     iString.Copy(fieldValDesC);
   343                     iString.Copy(fieldValDesC);
   335                     aTransaction.Close();
       
   336                     iHttpSession.Close();
       
   337                     iOwner.HttpEventL( EHttpAuthenticationNeeded, iString );
   344                     iOwner.HttpEventL( EHttpAuthenticationNeeded, iString );
   338                     }
   345                     }
   339                 else
   346                 else
   340                     {
   347                     {
   341                     // No location header. Can't use authentication -> redirect.
   348                     // No location header. Can't use authentication -> redirect.
   342                     aTransaction.Close();
       
   343                     iHttpSession.Close();
       
   344                     iOwner.HttpEventL( EConnectionNotOk, iString );    
   349                     iOwner.HttpEventL( EConnectionNotOk, iString );    
   345                     }
   350                     }
   346                 }
   351                 }
   347              else
   352              else
   348                 {
   353                 {
   349                 // Failed for other reason than redirect
   354                 // Failed for other reason than redirect
   350                 aTransaction.Close();
       
   351                 iHttpSession.Close();
       
   352                 iOwner.HttpEventL( EConnectionNotOk, iString );
   355                 iOwner.HttpEventL( EConnectionNotOk, iString );
   353                 }
   356                 }
   354               
   357               
   355               iString = KNullDesC;
   358               iString = KNullDesC;
   356             }
   359             }
   369             DEBUG("CIctsHttpHandler::THTTPEvent::ERedirectedTemporarily");
   372             DEBUG("CIctsHttpHandler::THTTPEvent::ERedirectedTemporarily");
   370             } 
   373             } 
   371             break;
   374             break;
   372     
   375     
   373         default:
   376         default:
   374            {
   377             {
   375            DEBUG1( "CIctsHttpHandler::MHFRunL::default iStatus: %d", aEvent.iStatus ); 
   378             DEBUG1( "CIctsHttpHandler::MHFRunL::default iStatus: %d", aEvent.iStatus ); 
   376            CTimer::Cancel();
   379             CTimer::Cancel();
   377            aTransaction.Close();
   380             if ( aEvent.iStatus < 0 )
   378            iHttpSession.Close();
   381                 {
   379            // close the transaction if it's an error
   382                 _LIT(string, "Unknown error");
   380            if ( aEvent.iStatus < 0 )
   383                 iString = string;
   381                {
   384                 iOwner.HttpEventL( EConnectionNotOk, iString );
   382                _LIT(string, "Unknown error");
   385                 }
   383                iString = string;
   386             else
   384                iOwner.HttpEventL( EConnectionNotOk, iString );
   387                 {
   385                }
   388                 _LIT(string, "Default");
   386            else
   389                 iString = string;
   387                {
   390                 iOwner.HttpEventL( EConnectionNotOk, iString );
   388                _LIT(string, "Default");
   391                 }
   389                iString = string;
       
   390                iOwner.HttpEventL( EConnectionNotOk, iString );
       
   391                }
       
   392             } 
   392             } 
   393             break;
   393             break;
   394         }
   394         }
   395     }
   395     }
   396 
   396