本文整理汇总了C++中HttpRequest::SetUri方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest::SetUri方法的具体用法?C++ HttpRequest::SetUri怎么用?C++ HttpRequest::SetUri使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::SetUri方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: HttpSession
void
Network::IsReachable(const String& hostAddr) {
String* pProxyAddr = null;
//String hostAddr = L"http://localhost:port";
AppLogDebug("Trying to reach...%S", hostAddr.GetPointer());
__pHttpSession = new HttpSession();
__pHttpSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, null);
HttpTransaction* pHttpTransaction = __pHttpSession->OpenTransactionN();
pHttpTransaction->AddHttpTransactionListener(*this);
HttpRequest* pHttpRequest = pHttpTransaction->GetRequest();
pHttpRequest->SetMethod(NET_HTTP_METHOD_GET);
pHttpRequest->SetUri(hostAddr);
pHttpTransaction->Submit();
}
示例4: hostAddr
void
UserProfileForm::SendRequestGet(String requestUrl)
{
result r = E_SUCCESS;
HttpRequest* pRequest = null;
String hostAddr(L"https://graph.facebook.com");
if(__pSession == null)
{
__pSession = new HttpSession();
r = __pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, null, hostAddr, null);
if (IsFailed(r))
{
AppLog("Fail to HttpSession::Construct. [%s]", GetErrorMessage(r));
return;
}
__pSession->SetAutoRedirectionEnabled(true);
}
__pTransaction = __pSession->OpenTransactionN();
if (__pTransaction)
{
result r = __pTransaction->AddHttpTransactionListener(*this);
pRequest = __pTransaction->GetRequest();
if (pRequest)
{
pRequest->SetUri(requestUrl);
pRequest->SetMethod(NET_HTTP_METHOD_GET);
r = __pTransaction->Submit();
AppLog("RequestUrl is =%ls",requestUrl.GetPointer());
if(IsFailed(r))
{
AppLog("Fail to HttpRequest::Submit. [%s]", GetErrorMessage(r));
}
}
else
{
delete __pTransaction;
__pTransaction = null;
}
}
}
示例5: main
int main() {
HttpClient http_client;
HttpRequest request;
request.SetHttpMethod("GET");
request.SetUri("http://127.0.0.1:12345/");
MemoryOutputStream body_output_stream(g_body_buffer, kBodySize);
HttpResponse response;
response.SetBodyOutputStream(&body_output_stream);
int ret = http_client.Request(request, &response);
/*
printf("header:\n%s\n\nbody:\n%s\n", response.m_header_stream.GetBufferString().c_str(), body_output_stream.GetBufferString().c_str());
response.ParseHttpHeader(response.m_header_stream);
*/
response.Print();
return ret;
}
示例6: 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;
}
示例7: hostAddr
HttpThread::HttpThread(std::string const & url,
downloader::IHttpThreadCallback & callback,
int64_t beg,
int64_t end,
int64_t size,
string const & pb)
: m_callback(callback),
m_begRange(beg), m_endRange(end),
m_downloadedBytes(0), m_expectedSize(size),
m_url(url), m_pb(pb),
m_pSession(0),
m_pTransaction(0)
{
result r = E_SUCCESS;
String * pProxyAddr = 0;
String hostAddr(m_url.c_str());
HttpHeader * header = 0;
LOG(LDEBUG, ("Creating HttpSession", m_url));
m_pSession = new HttpSession();
r = m_pSession->Construct(NET_HTTP_SESSION_MODE_NORMAL, pProxyAddr, hostAddr, header);
if (r != E_SUCCESS)
{
LOG(LERROR, ("HttpSession Construction error:", r));
return;
}
// Open a new HttpTransaction.
m_pTransaction = m_pSession->OpenTransactionN();
if ((r = GetLastResult()) != E_SUCCESS)
{
LOG(LERROR, ("OpenTransactionN", GetLastResult()));
return;
}
m_pTransaction->AddHttpTransactionListener(*this);
m_pTransaction->SetHttpProgressListener(*this);
HttpRequest * pRequest = m_pTransaction->GetRequest();
pRequest->SetUri(m_url.c_str());
HttpHeader * pHeader = pRequest->GetHeader();
// use Range header only if we don't download whole file from start
if (!(m_begRange == 0 && m_endRange < 0))
{
if (m_endRange > 0)
{
LOG(LDEBUG, (m_url, "downloading range [", m_begRange, ",", m_endRange, "]"));
String range("bytes=");
range.Append(m_begRange);
range.Append('-');
range.Append(m_endRange);
pHeader->AddField(L"Range", range);
}
else
{
LOG(LDEBUG, (m_url, "resuming download from position", m_begRange));
String range("bytes=");
range.Append(m_begRange);
range.Append('-');
pHeader->AddField("Range", range);
}
}
// set user-agent with unique client id only for mapswithme requests
if (m_url.find("mapswithme.com") != string::npos)
{
static string const uid = GetPlatform().UniqueClientId();
pHeader->AddField("User-Agent", uid.c_str());
}
if (m_pb.empty())
{
pRequest->SetMethod(NET_HTTP_METHOD_GET);
}
else
{
pRequest->SetMethod(NET_HTTP_METHOD_POST);
pHeader->AddField("Content-Type", "application/json");
int64_t const sz = m_pb.size();
String length;
length.Append(sz);
pHeader->AddField("Content-Length", length);
ByteBuffer body;
body.Construct((const byte *)m_pb.c_str(), 0, sz, sz);
pRequest->WriteBody(body);
}
LOG(LDEBUG, ("Connecting to", m_url, "[", m_begRange, ",", m_endRange, "]", "size=", m_expectedSize));
m_pTransaction->Submit();
}