applayerprotocols/httpservice/src/chttpservice.cpp
branchRCL_3
changeset 53 c59bddbfd7b9
parent 40 a0da872af3fa
equal deleted inserted replaced
40:a0da872af3fa 53:c59bddbfd7b9
    33 	CleanupStack::PushL(self);
    33 	CleanupStack::PushL(self);
    34 	self->ConstructL();
    34 	self->ConstructL();
    35 	CleanupStack::Pop(); // self
    35 	CleanupStack::Pop(); // self
    36 	return self;	
    36 	return self;	
    37 	}
    37 	}
       
    38 	
    38 /**
    39 /**
    39  * Destructor
    40  * Destructor
    40  * @publishedAll
    41  * @publishedAll
    41  * @prototype 
    42  * @prototype 
    42  */	
    43  */	
    50 	delete iHttpServiceStruct;
    51 	delete iHttpServiceStruct;
    51 	}
    52 	}
    52 
    53 
    53 /**
    54 /**
    54  * Destructor of the inner class CHttpServiceStruct
    55  * Destructor of the inner class CHttpServiceStruct
       
    56  *
    55  * @publishedAll
    57  * @publishedAll
    56  * @prototype 
    58  * @prototype 
    57  */ 
    59  */ 
    58 CHttpService::CHttpServiceStruct::~CHttpServiceStruct()
    60 CHttpService::CHttpServiceStruct::~CHttpServiceStruct()
    59     {
    61     {
    71  *          otherwise KErrNone for success
    73  *          otherwise KErrNone for success
    72  *
    74  *
    73  * @publishedAll
    75  * @publishedAll
    74  * @prototype 
    76  * @prototype 
    75  */
    77  */
    76 
       
    77 EXPORT_C TInt CHttpService::String(TInt aStringId, TPtrC8& aPtr)
    78 EXPORT_C TInt CHttpService::String(TInt aStringId, TPtrC8& aPtr)
    78     {
    79     {
    79     RStringF str = iHttpServiceStruct->iHttpSession.StringPool().StringF(aStringId, RHTTPSession::GetTable());
    80     RStringF str = iHttpServiceStruct->iHttpSession.StringPool().StringF(aStringId, RHTTPSession::GetTable());
    80     aPtr.Set(str.DesC());
    81     aPtr.Set(str.DesC());
    81     return KErrNone;
    82     return KErrNone;
    82     }
    83     }
    83 
    84     
    84 /**
    85 /**
    85  * Set the proxy that applies to all HTTP client transactions that "this"
    86  * Set the proxy that applies to all HTTP client transactions that "this"
    86  * CHttpService instance creates
    87  * CHttpService instance creates
    87  * 
    88  * 
    88  * @param aProxyAddress Proxy address. [for ex;  http://myproxy.org:8081]
    89  * @param aProxyAddress Proxy address. [for ex;  http://myproxy.org:8081]
    89  * @return KErrNoMemory if the proxy information cannot be set other KErrNone for success.
    90  * @return KErrNoMemory if the proxy information cannot be set other KErrNone for success.
    90  * 
    91  * 
    91  */
    92  */
    92 
       
    93 EXPORT_C TInt CHttpService::SetProxy(const TDesC8& aProxyAddress)
    93 EXPORT_C TInt CHttpService::SetProxy(const TDesC8& aProxyAddress)
    94 	{
    94 	{
    95 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
    95 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
    96 	RStringPool sp = sess.StringPool();
    96 	RStringPool sp = sess.StringPool();
    97 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
    97 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
   114 /**
   114 /**
   115  * Returns the proxy address that is set
   115  * Returns the proxy address that is set
   116  * 
   116  * 
   117  * @return Proxy address otherwise KNullDesC8 if the proxy information
   117  * @return Proxy address otherwise KNullDesC8 if the proxy information
   118  *         is not set.
   118  *         is not set.
   119  * 
   119  *
   120  * @publishedAll
   120  * @publishedAll
   121  * @prototype 
   121  * @prototype 
   122  */
   122  */
   123 
   123 
   124 EXPORT_C const TDesC8& CHttpService::ProxyAddress() const
   124 EXPORT_C const TDesC8& CHttpService::ProxyAddress() const
   141 /**
   141 /**
   142  * Set the maxuimum number of TCP connections[socket] CHttpService instance that can activated 
   142  * Set the maxuimum number of TCP connections[socket] CHttpService instance that can activated 
   143  * at any time. The default no. of connections that the CHttpService instance uses is 6.
   143  * at any time. The default no. of connections that the CHttpService instance uses is 6.
   144  * 
   144  * 
   145  * @param aValue aValue No. of connections
   145  * @param aValue aValue No. of connections
   146  * 
   146  *
   147  * @publishedAll
   147  * @publishedAll
   148  * @prototype 
   148  * @prototype 
   149  */
   149  */
   150 
   150 
   151 EXPORT_C void CHttpService::SetMaxConnections(TInt aValue)
   151 EXPORT_C void CHttpService::SetMaxConnections(TInt aValue)
   176 			return val.Int();
   176 			return val.Int();
   177 		}
   177 		}
   178 	return 0;
   178 	return 0;
   179 	}
   179 	}
   180 	
   180 	
   181 
       
   182 /**
   181 /**
   183  * Sets the maximum number of transactions to be pipelined.
   182  * Sets the maximum number of transactions to be pipelined.
   184  * @param aValue - number of transactions
   183  * @param aValue - number of transactions
   185  *
   184  *
   186  * @publishedAll
   185  * @publishedAll
   187  * @prototype 
   186  * @prototype 
   188  */ 
   187  */	
   189 EXPORT_C void CHttpService::SetMaxTransactionsToPipeline(TInt aValue)
   188 EXPORT_C void CHttpService::SetMaxTransactionsToPipeline(TInt aValue)
   190 	{
   189 	{
   191 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
   190 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
   192 	RStringPool sp = sess.StringPool();
   191 	RStringPool sp = sess.StringPool();
   193 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
   192 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
   198 /**
   197 /**
   199  * Returns the maximum number of transactions to be pipelined.
   198  * Returns the maximum number of transactions to be pipelined.
   200  * 
   199  * 
   201  * @publishedAll
   200  * @publishedAll
   202  * @prototype 
   201  * @prototype 
   203  */ 
   202  */		
   204 EXPORT_C TInt CHttpService::MaxTransactionsToPipeline() const
   203 EXPORT_C TInt CHttpService::MaxTransactionsToPipeline() const
   205 	{
   204 	{
   206 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
   205 	RHTTPSession sess = iHttpServiceStruct->iHttpSession;
   207 	RStringPool sp = sess.StringPool();
   206 	RStringPool sp = sess.StringPool();
   208 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
   207 	RHTTPConnectionInfo connInfo = sess.ConnectionInfo();
   218 /**
   217 /**
   219  * This method facilitates to set the header once in the CHttpService instance that is applicable
   218  * This method facilitates to set the header once in the CHttpService instance that is applicable
   220  * for all HTTP client transactions. [For ex; User-Agent header] 
   219  * for all HTTP client transactions. [For ex; User-Agent header] 
   221  * 
   220  * 
   222  * @param aStringId - Pre-defined String ID in the HTTP string pool
   221  * @param aStringId - Pre-defined String ID in the HTTP string pool
   223  * @param aHeaderValue - Value for the header
   222  * @param aHeaderValue - Value for the header 
   224  *  
   223  *
   225  * @publishedAll
   224  * @publishedAll
   226  * @prototype 
   225  * @prototype 
   227  */
   226  */
   228 EXPORT_C TInt CHttpService::AddRequestHeader(TInt aStringId, const THttpHeaderValueVariant& aHeaderValue)
   227 EXPORT_C TInt CHttpService::AddRequestHeader(TInt aStringId, const THttpHeaderValueVariant& aHeaderValue)
   229 	{
   228 	{
   238 /**
   237 /**
   239  * This method facilitates to set the custom HTTP header once in the CHttpService instance that is 
   238  * This method facilitates to set the custom HTTP header once in the CHttpService instance that is 
   240  * applicable for all HTTP client transactions. [For ex; User-Agent header] 
   239  * applicable for all HTTP client transactions. [For ex; User-Agent header] 
   241  * 
   240  * 
   242  * @param aHeaderName - Custom header name
   241  * @param aHeaderName - Custom header name
   243  * @param aHeaderValue - Value for the header
   242  * @param aHeaderValue - Value for the header 
   244  *  
   243  *
   245  * @publishedAll
   244  * @publishedAll
   246  * @prototype 
   245  * @prototype 
   247  */
   246  */
   248 EXPORT_C TInt CHttpService::AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue)
   247 EXPORT_C TInt CHttpService::AddCustomRequestHeader(const TDesC8& aHeaderName, const TDesC8& aHeaderValue)
   249 	{
   248 	{
   290     iHttpServiceStruct->iHttpSession.OpenL();
   289     iHttpServiceStruct->iHttpSession.OpenL();
   291     iHttpServiceStruct->iSessionHeaders = iHttpServiceStruct->iHttpSession.RequestSessionHeadersL();
   290     iHttpServiceStruct->iSessionHeaders = iHttpServiceStruct->iHttpSession.RequestSessionHeadersL();
   292     SetMaxConnections(KMaxNoOfConnections);
   291     SetMaxConnections(KMaxNoOfConnections);
   293     SetMaxTransactionsToPipeline(KMaxTransToPipeline);    
   292     SetMaxTransactionsToPipeline(KMaxTransToPipeline);    
   294 	}
   293 	}
   295 	
   294 
   296 /**
   295 /**
   297  * returns the CHttpNetworkConnection instance created by the framework.
   296  * returns the CHttpNetworkConnection instance created by the framework.
   298  * The class can be used to set the connection properties.
   297  * The class can be used to set the connection properties.
   299  *
   298  *
   300  * @publishedAll
   299  * @publishedAll
   304     {
   303     {
   305     CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New();
   304     CHttpNetworkConnection *httpNetworkConn = CHttpNetworkConnection::New();
   306     httpNetworkConn->SetHttpService(this);
   305     httpNetworkConn->SetHttpService(this);
   307     return httpNetworkConn;
   306     return httpNetworkConn;
   308     }
   307     }
       
   308 
   309 
   309 
   310 void CHttpService::RemoveUnwantedFilters()
   310 void CHttpService::RemoveUnwantedFilters()
   311     {
   311     {
   312     THTTPFilterRegistration filterInfo;
   312     THTTPFilterRegistration filterInfo;
   313     RStringPool stringPool = iHttpServiceStruct->iHttpSession.StringPool();
   313     RStringPool stringPool = iHttpServiceStruct->iHttpSession.StringPool();