当前位置: 首页>>代码示例>>C++>>正文


C++ HttpHeader::GetRawHeaderN方法代码示例

本文整理汇总了C++中HttpHeader::GetRawHeaderN方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpHeader::GetRawHeaderN方法的具体用法?C++ HttpHeader::GetRawHeaderN怎么用?C++ HttpHeader::GetRawHeaderN使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HttpHeader的用法示例。


在下文中一共展示了HttpHeader::GetRawHeaderN方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnTransactionReadyToRead

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;
		}
	}
}
开发者ID:JunminLee,项目名称:Winwin,代码行数:50,代码来源:Chatting.cpp

示例2:

void
UserProfileForm::OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool rs)
{

	HttpResponse* pHttpResponse = httpTransaction.GetResponse();
	if(pHttpResponse == null)
		return;
	HttpHeader* pHttpHeader = pHttpResponse->GetHeader();
	if(pHttpHeader != null)
	{
		String* tempHeaderString = pHttpHeader->GetRawHeaderN();
		AppLog("HeaderString=%ls\n",tempHeaderString->GetPointer());
	}

	AppLog("OnTransactionHeaderCompleted\n");
}
开发者ID:claymodel,项目名称:bigcloud,代码行数:16,代码来源:UserProfileForm.cpp

示例3: OnTransactionHeaderCompleted

void HttpThread::OnTransactionHeaderCompleted(HttpSession & httpSession,
                                              HttpTransaction & httpTransaction,
                                              int headerLen, bool bAuthRequired)
{
  result r = E_SUCCESS;
  HttpResponse * pResponse = httpTransaction.GetResponse();
  if ((r = GetLastResult()) != E_SUCCESS)
  {
    LOG(LWARNING, ("httpTransaction.GetResponse error", r));
    httpSession.CancelTransaction(httpTransaction);
    httpSession.CloseTransaction(httpTransaction);
    m_callback.OnFinish(-1, m_begRange, m_endRange);
    return;
  }

  int const httpStatusCode = pResponse->GetHttpStatusCode();
  // When we didn't ask for chunks, code should be 200
  // When we asked for a chunk, code should be 206
  bool const isChunk = !(m_begRange == 0 && m_endRange < 0);
  if ((isChunk && httpStatusCode != 206) || (!isChunk && httpStatusCode != 200))
  {
    LOG(LWARNING, ("Http request to", m_url, " aborted with HTTP code", httpStatusCode));
    httpSession.CancelTransaction(httpTransaction);
    r = httpSession.CloseTransaction(httpTransaction);
    m_callback.OnFinish(-4, m_begRange, m_endRange);
    LOG(LDEBUG, ("CloseTransaction result", r));
    return;
  }
  else if (m_expectedSize > 0)
  {
    bool bGoodSize = false;
    // try to get content length from Content-Range header first
    HttpHeader * pHeader = pResponse->GetHeader();
    LOG(LDEBUG, ("Header:", FromTizenString(*pHeader->GetRawHeaderN())));
    IEnumerator * pValues = pHeader->GetFieldValuesN("Content-Range");
    if (GetLastResult() == E_SUCCESS)
    {
      bGoodSize = true;
      pValues->MoveNext(); // strange, but works
      String const * pString = dynamic_cast<String const *>(pValues->GetCurrent());

      if (pString->GetLength())
      {
        int lastInd;
        pString->LastIndexOf ('/', pString->GetLength()-1, lastInd);
        int64_t value = -1;
        String tail;
        pString->SubString(lastInd + 1, tail);
        LOG(LDEBUG, ("tail value:",FromTizenString(tail)));
        LongLong::Parse(tail, value);
        if (value != m_expectedSize)
        {
          LOG(LWARNING, ("Http request to", m_url,
                         "aborted - invalid Content-Range:", value, " expected:", m_expectedSize ));
          httpSession.CancelTransaction(httpTransaction);
          r = httpSession.CloseTransaction(httpTransaction);
          m_callback.OnFinish(-2, m_begRange, m_endRange);
          LOG(LDEBUG, ("CloseTransaction result", r));
        }
      }
    }
    else
    {
      pValues = pHeader->GetFieldValuesN("Content-Length");
      if (GetLastResult() == E_SUCCESS)
      {
        bGoodSize = true;
        pValues->MoveNext();  // strange, but works
        String const * pString = dynamic_cast<String const *>(pValues->GetCurrent());
        if (pString)
        {
          int64_t value = -1;
          LongLong::Parse(*pString, value);
          if (value != m_expectedSize)
          {
            LOG(LWARNING, ("Http request to", m_url,
                           "aborted - invalid Content-Length:", value, " expected:", m_expectedSize));
            httpSession.CancelTransaction(httpTransaction);
            r = httpSession.CloseTransaction(httpTransaction);
            m_callback.OnFinish(-2, m_begRange, m_endRange);
            LOG(LDEBUG, ("CloseTransaction result", r));
          }
        }
      }
    }

    if (!bGoodSize)
    {
      LOG(LWARNING, ("Http request to", m_url,
                     "aborted, server didn't send any valid file size"));
      httpSession.CancelTransaction(httpTransaction);
      r = httpSession.CloseTransaction(httpTransaction);
      m_callback.OnFinish(-2, m_begRange, m_endRange);
      LOG(LDEBUG, ("CloseTransaction result", r));
    }
  }
}
开发者ID:DINKIN,项目名称:omim,代码行数:97,代码来源:http_thread_tizen.cpp


注:本文中的HttpHeader::GetRawHeaderN方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。