Exemplo n.º 1
0
void Chatting::OnTransactionReadyToRead(
		Tizen::Net::Http::HttpSession& httpSession,
		Tizen::Net::Http::HttpTransaction& httpTransaction,
		int availableBodyLen) {
	AppLog("OnTransactionReadyToRead");

	HttpResponse* pHttpResponse = httpTransaction.GetResponse();
	if (pHttpResponse->GetHttpStatusCode() == HTTP_STATUS_OK) {
		HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
		if (pHttpHeader != null) {
			String* tempHeaderString = pHttpHeader->GetRawHeaderN();
			ByteBuffer* pBuffer = pHttpResponse->ReadBodyN();
			AppLog((const char*)pBuffer->GetPointer());
			String str((const char*) (pBuffer->GetPointer()));

//			IJsonValue* pJson = JsonParser::ParseN(*pBuffer);
//
//			JsonObject *pObject = static_cast<JsonObject*>(pJson);
//
//			   JsonString *userName = new JsonString("username");
//			   IJsonValue *pValName = null;
//
//			   JsonString *dates = new JsonString("date");
//			   IJsonValue *pValDate = null;
//
//
//			   pObject->GetValue(userName, pValName);
//			   pObject->GetValue(dates,pValDate);
//
//
//			   JsonString* pName = static_cast<JsonString*>(pValName);
//			   JsonString* pDate= static_cast<JsonString*>(pValDate);
//
//			   String text(L"이름: ");
//			   text.Append(*pName);
//			   text.Append("\n날짜: ");
//			   text.Append(*pDate);

//	String text(str);
//	text.Append(availableBodyLen);

//	__pEditArea->SetText(text);

			Draw();

			delete tempHeaderString;
			delete pBuffer;
		}
	}
}
Exemplo n.º 2
0
void HttpThread::OnHttpDownloadInProgress(HttpSession & /*httpSession*/,
                                          Tizen::Net::Http::HttpTransaction & httpTransaction,
                                          int64_t currentLength,
                                          int64_t totalLength)
{
  HttpResponse * pResponse = httpTransaction.GetResponse();
  if (pResponse->GetHttpStatusCode() == HTTP_STATUS_OK || pResponse->GetHttpStatusCode() == HTTP_STATUS_PARTIAL_CONTENT)
  {
    ByteBuffer * pBuffer = 0;
    pBuffer = pResponse->ReadBodyN();
    int const chunkSize = pBuffer->GetLimit();
    m_downloadedBytes += chunkSize;
    m_callback.OnWrite(m_begRange + m_downloadedBytes - chunkSize, pBuffer->GetPointer(), chunkSize);
    delete pBuffer;
  }
  else
    LOG(LERROR, ("OnHttpDownloadInProgress ERROR", FromTizenString(pResponse->GetStatusText())));
}