Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/httpexampleclient_8h-source.html
Week 12 contribution of SDK documentation_content. See release notes for details. Fixes Bug 1892, Bug 1522, Bug 1520, Bug 394, Bug 1319, Bug 344, Bug 1897
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>TB10.1 Example Applications: examples/AppProts/exampleclient/httpexampleclient.h Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.3 -->
<h1>examples/AppProts/exampleclient/httpexampleclient.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">// This component and the accompanying materials are made available</span>
<a name="l00004"></a>00004 <span class="comment">// under the terms of "Eclipse Public License v1.0"</span>
<a name="l00005"></a>00005 <span class="comment">// which accompanies this distribution, and is available</span>
<a name="l00006"></a>00006 <span class="comment">// at the URL "http://www.eclipse.org/legal/epl-v10.html".</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">// Initial Contributors:</span>
<a name="l00009"></a>00009 <span class="comment">// Nokia Corporation - initial contribution.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// Contributors:</span>
<a name="l00012"></a>00012 <span class="comment">//</span>
<a name="l00013"></a>00013 <span class="comment">// Description:</span>
<a name="l00014"></a>00014 <span class="comment">// HTTPEXAMPLECLIENT is a simple text based http client. </span>
<a name="l00015"></a>00015 <span class="comment">// It is intended as an example and introduction to the HTTP Client API's available in </span>
<a name="l00016"></a>00016 <span class="comment">// The Symbian Platform Release 6.2</span>
<a name="l00017"></a>00017 <span class="comment">// Users should have a brief understanding of HTTP and the different types of requests and responses you can get</span>
<a name="l00018"></a>00018 <span class="comment">// from servers. They should also be familiar with setting up a communications database (cdbv2.dat) with suitable settings</span>
<a name="l00019"></a>00019 <span class="comment">// for modems/NTRas and ISP's.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021
<a name="l00022"></a>00022
<a name="l00023"></a>00023
<a name="l00024"></a>00024 <span class="preprocessor">#include <e32test.h></span>
<a name="l00025"></a>00025 <span class="preprocessor">#include <f32file.h></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include <http/mhttpauthenticationcallback.h></span>
<a name="l00027"></a>00027
<a name="l00028"></a>00028 <span class="comment">// Maximum size of buffer to hold content-type data</span>
<a name="l00029"></a>00029 <span class="comment">//</span>
<a name="l00030"></a>00030 <span class="keyword">const</span> TInt KMaxContentTypeSize = 64;
<a name="l00031"></a>00031
<a name="l00032"></a>00032
<a name="l00033"></a>00033 <span class="comment">//</span>
<a name="l00034"></a>00034 <span class="comment">// Definition of CHttpClient</span>
<a name="l00035"></a>00035 <span class="comment">//</span>
<a name="l00036"></a>00036 <span class="keyword">class </span><a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>;
<a name="l00037"></a>00037 <span class="keyword">class </span><a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>;
<a name="l00038"></a>00038
<a name="l00039"></a>00039
<a name="l00048"></a><a class="code" href="class_c_http_client.html">00048</a> <span class="keyword">class </span><a class="code" href="class_c_http_client.html">CHttpClient</a> : <span class="keyword">public</span> CBase, <span class="keyword">public</span> MHTTPDataSupplier,
<a name="l00049"></a>00049 <span class="keyword">public</span> MHTTPAuthenticationCallback
<a name="l00050"></a>00050 {
<a name="l00051"></a>00051 <span class="keyword">public</span>:
<a name="l00052"></a>00052 <span class="keyword">virtual</span> <a class="code" href="class_c_http_client.html#33c02fb95218215e3289f560713597ce">~CHttpClient</a>();
<a name="l00053"></a>00053 <span class="keyword">static</span> <a class="code" href="class_c_http_client.html">CHttpClient</a>* <a class="code" href="class_c_http_client.html#c629afd9dba45056a81a58be2a94a5c5">NewLC</a>();
<a name="l00054"></a>00054 <span class="keyword">static</span> <a class="code" href="class_c_http_client.html">CHttpClient</a>* <a class="code" href="class_c_http_client.html#f62107c868da9904c92ffe6b726dc222">NewL</a>();
<a name="l00055"></a>00055 <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#0f39c19552deec488b5fa98fa9f9d929">StartClientL</a>();
<a name="l00056"></a>00056 <span class="comment">// methods inherited from MHTTPDataSupplier</span>
<a name="l00057"></a>00057 <span class="keyword">virtual</span> TBool <a class="code" href="class_c_http_client.html#a296adbd23a0df0c7aacdee6d44b25f0">GetNextDataPart</a>(TPtrC8& aDataPart);
<a name="l00058"></a>00058 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#c9ebeda59a1c72795f56b84c18da6ae4">ReleaseData</a>();
<a name="l00059"></a>00059 <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_client.html#21f73ccc81e3025a99fc56b3d5cb3d1d">OverallDataSize</a>();
<a name="l00060"></a>00060 <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_client.html#58dcb78f4fd957522ee44b42b721b021">Reset</a>();
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">// methods inherited from MHTTPAuthenticationCallback</span>
<a name="l00063"></a>00063 <span class="keyword">virtual</span> TBool <a class="code" href="class_c_http_client.html#e154d7b4e42475225582afc5bde9c53a">GetCredentialsL</a>(<span class="keyword">const</span> TUriC8& aURI, RString aRealm,
<a name="l00064"></a>00064 RStringF aAuthenticationType,
<a name="l00065"></a>00065 RString& aUsername,
<a name="l00066"></a>00066 RString& aPassword);
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="keyword">protected</span>:
<a name="l00069"></a>00069 <a class="code" href="class_c_http_client.html#845a9f4ee99a401b8e5f719af489e970">CHttpClient</a>();
<a name="l00070"></a>00070 <span class="keywordtype">void</span> <a class="code" href="class_c_http_client.html#38d577b3c8c8a3cd740e1b9be9224b91">ConstructL</a>();
<a name="l00071"></a>00071 <span class="keyword">private</span>:
<a name="l00072"></a>00072
<a name="l00073"></a>00073 <span class="keyword">enum</span> TMenuItems
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 EGet,
<a name="l00076"></a>00076 EPost,
<a name="l00077"></a>00077 EHead,
<a name="l00078"></a>00078 ETrace,
<a name="l00079"></a>00079 EToggleVerbosity,
<a name="l00080"></a>00080 EQuit
<a name="l00081"></a>00081 };
<a name="l00082"></a>00082
<a name="l00083"></a>00083 <span class="keywordtype">void</span> ResetTimeElapsed();
<a name="l00084"></a>00084 <span class="keywordtype">void</span> DisplayTimeElapsed();
<a name="l00085"></a>00085 <span class="comment">//</span>
<a name="l00086"></a>00086 <span class="keywordtype">void</span> InvokeHttpMethodL(<span class="keyword">const</span> TDesC8& aUri, RStringF aMethod);
<a name="l00087"></a>00087 <span class="keywordtype">void</span> SetHeaderL(RHTTPHeaders aHeaders, TInt aHdrField, <span class="keyword">const</span> TDesC8& aHdrValue);
<a name="l00088"></a>00088 <span class="keywordtype">void</span> GetRequestBodyL(RStringF& aMethod);
<a name="l00089"></a>00089 <span class="keywordtype">void</span> GetPostBodyManuallyL();
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="keyword">private</span>:
<a name="l00092"></a>00092 TTime iLastTimeStamp;
<a name="l00093"></a>00093 TInt iDataChunkCount;
<a name="l00094"></a>00094 RHTTPSession iSess;
<a name="l00095"></a>00095 RHTTPTransaction iTrans;
<a name="l00096"></a>00096 TBool iHasARequestBody;
<a name="l00097"></a>00097 RFs iFileServ;
<a name="l00098"></a>00098 RFile iReqBodyFile;
<a name="l00099"></a>00099 TFileName iReqBodyFileName;
<a name="l00100"></a>00100 TParse iParsedFileName;
<a name="l00101"></a>00101 TBuf<KMaxContentTypeSize> iReqBodyContentType;
<a name="l00102"></a>00102 <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* iTransObs;
<a name="l00103"></a>00103 HBufC8* iReqBodySubmitBuffer;
<a name="l00104"></a>00104 TPtr8 iReqBodySubmitBufferPtr;
<a name="l00105"></a>00105 CHTTPFormEncoder* iFormEncoder; <span class="comment">// used for manual post submissions</span>
<a name="l00106"></a>00106 TBool iManualPost;
<a name="l00107"></a>00107 <a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>* iUtils;
<a name="l00108"></a>00108 };
<a name="l00109"></a>00109
<a name="l00110"></a>00110
<a name="l00111"></a>00111
<a name="l00114"></a><a class="code" href="class_c_http_event_handler.html">00114</a> <span class="keyword">class </span><a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a> : <span class="keyword">public</span> CBase, <span class="keyword">public</span> MHTTPTransactionCallback
<a name="l00115"></a>00115 {
<a name="l00116"></a>00116 <span class="keyword">public</span>:
<a name="l00117"></a>00117 <span class="keyword">virtual</span> <a class="code" href="class_c_http_event_handler.html#f0c5dbd7a9db37f99a303ccd70d07f2b">~CHttpEventHandler</a>();
<a name="l00118"></a>00118 <span class="keyword">static</span> <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* <a class="code" href="class_c_http_event_handler.html#4e22bb739a6ee13185d22dda382c2fb1">NewLC</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>& aUtils);
<a name="l00119"></a>00119 <span class="keyword">static</span> <a class="code" href="class_c_http_event_handler.html">CHttpEventHandler</a>* <a class="code" href="class_c_http_event_handler.html#9f822eb7d70103589216653878a6a3fc">NewL</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>& aUtils);
<a name="l00120"></a>00120 <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#976804deb934b33ed62a3f2245ce5019">SetVerbose</a>(TBool aVerbose);
<a name="l00121"></a>00121 TBool <a class="code" href="class_c_http_event_handler.html#508fdfdc104001adf4a57a6105d81b27">Verbose</a>() <span class="keyword">const</span>;
<a name="l00122"></a>00122 <span class="comment">//</span>
<a name="l00123"></a>00123 <span class="comment">// methods from MHTTPTransactionCallback</span>
<a name="l00124"></a>00124 <span class="comment">//</span>
<a name="l00125"></a>00125 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#4834f458326a10126d8b0b149394e35e">MHFRunL</a>(RHTTPTransaction aTransaction, <span class="keyword">const</span> THTTPEvent& aEvent);
<a name="l00126"></a>00126 <span class="keyword">virtual</span> TInt <a class="code" href="class_c_http_event_handler.html#5ea099b761ad15cf308ddc939afea3d4">MHFRunError</a>(TInt aError, RHTTPTransaction aTransaction, <span class="keyword">const</span> THTTPEvent& aEvent);
<a name="l00127"></a>00127
<a name="l00128"></a>00128 <span class="keyword">protected</span>:
<a name="l00129"></a>00129 <a class="code" href="class_c_http_event_handler.html#321925f9d78dcecfa990fe56e9aaf7f9">CHttpEventHandler</a>(<a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>& aUtils);
<a name="l00130"></a>00130 <span class="keywordtype">void</span> <a class="code" href="class_c_http_event_handler.html#9bab82a1ec81a955cee1387efd8bde1e">ConstructL</a>();
<a name="l00131"></a>00131 <span class="keyword">private</span>:
<a name="l00132"></a>00132 <span class="keywordtype">void</span> DumpRespHeadersL(RHTTPTransaction& aTrans);
<a name="l00133"></a>00133 <span class="keywordtype">void</span> DumpRespBody(RHTTPTransaction& aTrans);
<a name="l00134"></a>00134 <span class="keywordtype">void</span> DumpIt(<span class="keyword">const</span> TDesC8& aData);
<a name="l00135"></a>00135 TBool iVerbose;
<a name="l00136"></a>00136 TBool iSavingResponseBody;
<a name="l00137"></a>00137 RFs iFileServ;
<a name="l00138"></a>00138 RFile iRespBodyFile;
<a name="l00139"></a>00139 TFileName iRespBodyFileName;
<a name="l00140"></a>00140 TParse iParsedFileName;
<a name="l00141"></a>00141 MHTTPDataSupplier* iRespBody;
<a name="l00142"></a>00142 <a class="code" href="class_c_http_example_utils.html">CHttpExampleUtils</a>& iUtils; <span class="comment">// not owned</span>
<a name="l00143"></a>00143 };
<a name="l00144"></a>00144
</pre></div><hr size="1"><address style="text-align: right;"><small>Generated on Thu Jan 21 10:32:55 2010 for TB10.1 Example Applications by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.3 </small></address>
</body>
</html>