symbian 使用http get post方式获取网页信息
2010-05-31 19:38:00 来源:WEB开发网115. // ----------------------------------------------------------------------------
116. void CClientEngine::SetHeaderL(RHTTPHeaders aHeaders,//设置一个http包头
117. TInt aHdrField,
118. const TDesC8& aHdrValue)
119. {
120. RStringF valStr = iSession.StringPool().OpenFStringL(aHdrValue);
121. CleanupClosePushL(valStr);
122. THTTPHdrVal val(valStr);
123. aHeaders.SetFieldL(iSession.StringPool().StringF(aHdrField,
124. RHTTPSession::GetTable()), val);
125. CleanupStack::PopAndDestroy(); // valStr
126. }
127.
128. // ----------------------------------------------------------------------------
129. // CClientEngine::IssueHTTPGetL()
130. //
131. // Start a new HTTP GET transaction.
132. // ----------------------------------------------------------------------------
133. void CClientEngine::IssueHTTPGetL(const TDesC8& aUri)//以get方式获取一个网页
134. {
135. SetupConnectionL();
136.
137. // Parse string to URI (as defined in RFC2396)
138. TUriParser8 uri;
139. uri.Parse(aUri);//把传入的uri转化为标准格式
140. // Get request method string for HTTP GET
141. RStringF method = iSession.StringPool().StringF(HTTP::EGET,
142. RHTTPSession::GetTable());//设置以get的方法读取
143. // Open transaction with previous method and parsed uri. This class will
144. // receive transaction events in MHFRunL and MHFRunError.
145. iTransaction = iSession.OpenTransactionL(uri, *this, method);//打开一个连接 使用设置好的方法和指定的uri
146. // Set headers for request; user agent and accepted content type
147. RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();//设置一个http头
更多精彩
赞助商链接