xdmprotocols/XcapProtocol/XcapHttpTransport/inc/XcapHttpRequest.h
branchRCL_3
changeset 34 2669f8761a99
parent 31 2580314736af
child 35 fbd2e7cec7ef
equal deleted inserted replaced
31:2580314736af 34:2669f8761a99
     1 /*
       
     2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   CXcapHttpRequest
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __XCAPHTTPREQUEST__
       
    22 #define __XCAPHTTPREQUEST__
       
    23 
       
    24 // INCLUDES
       
    25 #include <http.h>
       
    26 #include "XdmOperation.h"
       
    27 #include "XcapHttpRequestTimerCallback.h"
       
    28 
       
    29 //CONSTANTS
       
    30 //const TInt KMaxNumberOfRetries                    = 3;
       
    31 const TInt KAuthTypeProxy                           = 407;
       
    32 const TInt KAuthTypeNormal                          = 401;
       
    33 
       
    34 _LIT8( KXcapRequestPost,                            "POST" );
       
    35 _LIT8( KXcapRequestGet,                             "GET" );
       
    36 _LIT8( KXcapRequestPut,                             "PUT" );
       
    37 _LIT8( KXcapRequestDelete,                          "DELETE" );
       
    38 		
       
    39 _LIT8( KHttpHeaderAccept,                           "Accept" );
       
    40 _LIT8( KHttpHeaderIfMatch,                          "If-Match" );
       
    41 _LIT8( KHttpHeaderIfNoneMatch,                      "If-None-Match" );
       
    42 _LIT8( KHttpHeaderContentType,                      "Content-Type" );
       
    43 _LIT8( KHttpHeaderIntIdentity,                      "X-3GPP-Intended-Identity" );
       
    44 
       
    45 //FORWARD DECLARATIONS
       
    46 class TXdmCredentials;
       
    47 class CXcapHttpResponse;
       
    48 class CXcapHttpTransport;
       
    49 class CXcapHttpHeaderModel;
       
    50 class CXcapHttpAuthManager;
       
    51 class CXcapHttpRequestTimer;
       
    52 
       
    53 // CLASS DECLARATION
       
    54 class CXcapHttpRequest : public CBase,
       
    55                          public MXcapHttpRequestTimerCallback
       
    56 
       
    57     {
       
    58     public:
       
    59         
       
    60         /**
       
    61         * C++ default constructor is private.
       
    62         */     
       
    63         IMPORT_C void SetHeaderL( const TDesC8& aHeaderName,
       
    64                                   const TDesC8& aHeaderValue );
       
    65 
       
    66         /**
       
    67         * Sets the expiry time of this transaction
       
    68         * @param aExpiryTime Time period after which this transaction expires
       
    69         * @param aCallback Handle to the receiver of the expiry event
       
    70         */
       
    71         IMPORT_C void SetExpiryTimeL( MXcapHttpRequestTimerCallback* aCallback,
       
    72                                       const TTimeIntervalMicroSeconds32 aExpiryTime );
       
    73         
       
    74         /**
       
    75         * Cancel this transaction
       
    76         */
       
    77         IMPORT_C void CancelRequest();
       
    78         
       
    79         /**
       
    80         * C++ default constructor is private.
       
    81         */     
       
    82         IMPORT_C void DispatchRequestL( TRequestStatus& aClientStatus );
       
    83         
       
    84         /**
       
    85         * Sets the expiry time of this transaction
       
    86         * @param aExpiryTime Time period after which this transaction expires
       
    87         * @param aCallback Handle to the receiver of the expiry event
       
    88         */
       
    89         IMPORT_C void ResetUriL( const TDesC& aNewUri );
       
    90         
       
    91         /**
       
    92         * Sets the expiry time of this transaction
       
    93         * @param aExpiryTime Time period after which this transaction expires
       
    94         * @param aCallback Handle to the receiver of the expiry event
       
    95         */
       
    96         IMPORT_C void UpdateRequestUriL( const TDesC8& aUpdatedUri );
       
    97         
       
    98         /**
       
    99         * Sets the expiry time of this transaction
       
   100         * @param aExpiryTime Time period after which this transaction expires
       
   101         * @param aCallback Handle to the receiver of the expiry event
       
   102         */
       
   103         IMPORT_C TPtrC8 RequestUriL() const;
       
   104         
       
   105         /**
       
   106         * Sets the expiry time of this transaction
       
   107         * @param aExpiryTime Time period after which this transaction expires
       
   108         * @param aCallback Handle to the receiver of the expiry event
       
   109         */
       
   110         IMPORT_C TPtrC8 HeaderValue( const HTTP::TStrings aHeaderName ) const;
       
   111 
       
   112         /**
       
   113         * C++ default constructor is private.
       
   114         */   
       
   115         IMPORT_C TXdmCompletionData* ResponseData();
       
   116         
       
   117         /**
       
   118         * C++ default constructor is private.
       
   119         */   
       
   120         IMPORT_C void ReleaseResponseData();
       
   121         
       
   122         /**
       
   123         * Destructor.
       
   124         */      
       
   125         IMPORT_C virtual ~CXcapHttpRequest();
       
   126 
       
   127     public:
       
   128         
       
   129         /**
       
   130         * Try to resend this request
       
   131         * @return TBool Resent or not
       
   132         */
       
   133         TPtrC8 RelativeUri() const;
       
   134         
       
   135         /**
       
   136         * Try to resend this request
       
   137         * @return TBool Resent or not
       
   138         */
       
   139         void ResendWithAuthL( TInt aAuthtype );
       
   140                 
       
   141         /**
       
   142         * Has this transaction been cancelled.
       
   143         * @return TBool
       
   144         */
       
   145         CXcapHttpAuthManager& AuthManager();
       
   146         
       
   147         /**
       
   148         * C++ default constructor is private.
       
   149         */      
       
   150         RHTTPSession& Session();
       
   151 
       
   152         /**
       
   153         * Return the HTTP transaction associated with this transaction
       
   154         * @return RHTTPTransaction
       
   155         */
       
   156         RHTTPTransaction& Transaction();
       
   157         
       
   158         /**
       
   159         * C++ default constructor is private.
       
   160         */     
       
   161         void AppendDataL( const TPtrC8& aBodyPart );
       
   162 
       
   163         /**
       
   164         * Complete this request
       
   165         * @param aErrorCode The completion code
       
   166         */
       
   167         void FinaliseRequestL( TInt aErrorCode );
       
   168 
       
   169 
       
   170     protected:  // Constructors and destructor
       
   171         
       
   172         /**
       
   173         * C++ default constructor is private.
       
   174         */      
       
   175         CXcapHttpRequest( RHTTPSession& aHttpSession,
       
   176                           CXcapHttpAuthManager& aAuthManager,
       
   177                           CXcapHttpTransport& aTransportMain );
       
   178 
       
   179         /**
       
   180         * Copies the request data
       
   181         * @param aRequestData Data to be sent
       
   182         */
       
   183         void BaseConstructL( const TDesC& aRequestUri );
       
   184 
       
   185         /**
       
   186         * Copies the request data
       
   187         * @param aRequestData Data to be sent
       
   188         */
       
   189         virtual void ConstructRequestL();
       
   190 
       
   191         /**
       
   192         * Append data to the response buffer.
       
   193         */
       
   194         virtual RStringF ConstructMethodStringL() = 0;
       
   195         
       
   196         /**
       
   197         * Sets the status of this transaction
       
   198         * @param aSent Has this transaction been sent or not
       
   199         */
       
   200         void SetStatus( const TBool aSent );
       
   201 
       
   202         /**
       
   203         * Has this transaction been cancelled.
       
   204         * @return TBool
       
   205         */
       
   206         TBool IsCancelled();
       
   207 
       
   208         /**
       
   209         * Has this transaction been sent
       
   210         * @return TBool
       
   211         */
       
   212         TBool Status() const;
       
   213 
       
   214         /**
       
   215         * Return the time stamp of this transaction
       
   216         * @return TInt 
       
   217         */
       
   218         const TInt SendTime() const;
       
   219 
       
   220         /**
       
   221         * Get the current time (System tick count)
       
   222         */
       
   223         TInt TimeL() const;
       
   224 
       
   225     private:
       
   226         
       
   227         /**
       
   228         * Second-phase constructor.
       
   229         */ 
       
   230         void ConstructL( const TDesC8& aRequestBody );
       
   231         
       
   232         /**
       
   233         * Second-phase constructor.
       
   234         */ 
       
   235         void DoSetHeadersL();
       
   236         
       
   237         /**
       
   238         * Second-phase constructor.
       
   239         */ 
       
   240         void RemoveDuplicateAuth();
       
   241         
       
   242         /**
       
   243         * Append authorization header
       
   244         */ 
       
   245         void AppendAuthorizationHeaderL( RHTTPHeaders& aHeaderCollection, TInt aAuthType );
       
   246         
       
   247         /**
       
   248         * Second-phase constructor.
       
   249         */ 
       
   250         void SetRequestUriL( const TDesC& aRequestUri );
       
   251         
       
   252         /**
       
   253         * Second-phase constructor.
       
   254         */ 
       
   255         void PrepareResponseBodyL();
       
   256     
       
   257     #ifdef _DEBUG
       
   258        
       
   259         /**
       
   260         * Second-phase constructor.
       
   261         */ 
       
   262         void DumpResponseL( const TDesC8& aRespData, const TDesC& aDumpName );
       
   263         
       
   264     #endif
       
   265     
       
   266         /**
       
   267         * Second-phase constructor.
       
   268         */ 
       
   269         void CompileResponseDataL( TInt aErrorCode );
       
   270         
       
   271         /**
       
   272         * Second-phase constructor.
       
   273         */ 
       
   274         TInt ReinterpretErrorCode( const TInt aHttpStatus ) const;
       
   275         
       
   276         /**
       
   277         * Second-phase constructor.
       
   278         */ 
       
   279         virtual void HandleTimerEventL();
       
   280     
       
   281     protected: //Data
       
   282         
       
   283         RHTTPSession&                           iHttpSession;
       
   284         RHTTPTransaction                        iHttpTransaction;
       
   285         CXcapHttpTransport&                     iTransportMain;
       
   286 
       
   287     private: //Data
       
   288         
       
   289         HBufC8*                                 iFlatResponse;
       
   290         HBufC8*                                 iRequestUriBuf;
       
   291         HBufC8*                                 iWholeUri;
       
   292         CXcapHttpResponse*                      iHttpResponse;
       
   293         CBufSeg*                                iResponseBuffer;
       
   294         TRequestStatus*                         iClientStatus;
       
   295         CXcapHttpRequestTimer*                  iExpiryTimer;
       
   296         TUriParser8                             iRequestUri;
       
   297         TInt                                    iCurrentDataLength;
       
   298         TInt                                    iNumberOfRetries;
       
   299         TInt                                    iSendTime;
       
   300         TBool                                   iSent;
       
   301         TBool                                   iActive;
       
   302         TBool                                   iCancelled;
       
   303         TBool                                   iConstructed;
       
   304         TXdmCompletionData                      iRespData;
       
   305         CXcapHttpAuthManager&                   iAuthManager;
       
   306         TTimeIntervalMicroSeconds32             iExpiryTime;
       
   307         RPointerArray<CXcapHttpHeaderModel>     iHeaderCollection;
       
   308     };
       
   309 
       
   310 #endif
       
   311 
       
   312 // End of File