本文整理汇总了C++中HttpSession::Construct方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpSession::Construct方法的具体用法?C++ HttpSession::Construct怎么用?C++ HttpSession::Construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpSession
的用法示例。
在下文中一共展示了HttpSession::Construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: User
void
ProjectGiraffeTab1::updateItems()
{
#if kDebugUseDummyItems
AppLog("Creating dummy items");
User *dummyUser = new User();
dummyUser->setUsername(L"Username");
for (int i = 0; i < 10; i++) {
Graffiti *graffiti = new Graffiti();
graffiti->setUser(dummyUser);
graffiti->setText(L"dummy string");
_items->Add(graffiti);
}
#else
#if kDebugUseHttpConnection
double latitude = ProjectGiraffeMainForm::currentLatitude;
double longitude = ProjectGiraffeMainForm::currentLongitude;
HttpConnection *connection = HttpConnection::graffitiNearbyGetConnection(this,latitude,longitude);
connection->begin();
#else
// Kick off http request for items based on location.
// Populate item source array
HttpSession* pHttpSession = null;
HttpTransaction* pHttpTransaction = null;
String* pProxyAddr = null;
String hostAddr = L"http://ec2-54-243-69-6.compute-1.amazonaws.com/";
String uri = L"http://ec2-54-243-69-6.compute-1.amazonaws.com/";
AppLog("Starting the HTTP Session");
pHttpSession = new HttpSession();
// HttpSession construction.
pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null);
// Open a new HttpTransaction.
pHttpTransaction = pHttpSession->OpenTransactionN();
// Add a listener.
pHttpTransaction->AddHttpTransactionListener(*this);
// Get an HTTP request.
HttpRequest* pHttpRequest = pHttpTransaction->GetRequest();
// Set the HTTP method and URI:
pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
pHttpRequest->SetUri(uri);
// Submit the request:
pHttpTransaction->Submit();
#endif
#endif
}
示例2: getTrip
String IRailConnection::getTrip(String &from, String &to,TrainsResultsForm *pTrainsResultsForm) {
this->pTrainsResultsForm = pTrainsResultsForm;
result r = E_SUCCESS;
String* pProxyAddr = null;
String hostAddr = L"http://api.irail.be";
String hostAddr2(L"http://api.irail.be/connections/?to=");
hostAddr2.Append(to);
hostAddr2.Append(L"&from=");
hostAddr2.Append(from);
HttpSession* pSession = null;
HttpTransaction* pTransaction = null;
pSession = new HttpSession();
r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr ,hostAddr,null);
if (IsFailed(r))
{
AppLog("Construct Session failed. (%s)\n", GetErrorMessage(r));
}
pTransaction = pSession->OpenTransactionN();
if (null == pTransaction)
{
AppLog("Construct Session failed. \n");
}
r = pTransaction->AddHttpTransactionListener(*this);
if (IsFailed(r))
{
AppLog("AddHttpTransactionListener Session failed.\n");
}
HttpRequest* pRequest = pTransaction->GetRequest();
if(pRequest == null)
{
AppLog("GetRequest failed. \n");
}
r = pRequest->SetUri(hostAddr2);
if(IsFailed(r))
{
AppLog("SetUri failed. (%s)\n", GetErrorMessage(r));
}
r = pRequest->SetMethod(NET_HTTP_METHOD_GET);
if(IsFailed(r))
{
AppLog("SetMethod failed. (%s)\n", GetErrorMessage(r));
}
r = pTransaction->Submit();
if(IsFailed(r))
{
AppLog("Submit failed. (%s)\n", GetErrorMessage(r));
}
return hostAddr;
}
示例3: RequestHttpPost
result Chatting::RequestHttpPost(void) {
result r = E_SUCCESS;
HttpSession* pSession = null;
HttpTransaction* pTransaction = null;
HttpRequest* pRequest = null;
HttpMultipartEntity* pMultipartEntity = null;
String hostAddr(HTTP_CLIENT_HOST_ADDRESS);
// Creates an HTTP session.
pSession = new HttpSession();
r = pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
pTransaction = pSession->OpenTransactionN();
r = pTransaction->AddHttpTransactionListener(*this);
// r = pTransaction->SetHttpProgressListener(*this);
pRequest = pTransaction->GetRequest();
pRequest->SetMethod(NET_HTTP_METHOD_POST);
r = pRequest->SetUri(HTTP_CLIENT_REQUEST_URI);
pMultipartEntity = new HttpMultipartEntity();
r = pMultipartEntity->Construct();
String me = __pEditField->GetText();
Tizen::Text::Encoding* pEnc = Tizen::Text::Encoding::GetEncodingN(L"UTF-8");
pMultipartEntity->AddStringPart(L"message", me, L"text/plain", L"UTF-8",
*pEnc);
r = pMultipartEntity->AddStringPart(L"friendIdRegId", resultRegId);
r = pRequest->SetEntity(*pMultipartEntity);
r = pTransaction->Submit();
return r;
}