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


C++ HttpMessage::getResponseStatusText方法代码示例

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


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

示例1: run

int ACDAudio::run(void* pArg)
{
   Os::Logger::instance().log(FAC_ACD, gACD_DEBUG, "ACDAudio::run - starting get from: %s", mUriString.data());

   HttpMessage *pGetRequest = new HttpMessage;

   pGetRequest->get(mUri, HTTP_GET_TIMEOUT);

   UtlString status;

   pGetRequest->getResponseStatusText(&status);

   if (status == "OK") {
      UtlString audioData;
      ssize_t audioLength;

      const HttpBody* pResponseBody = pGetRequest->getBody();
      pResponseBody->getBytes(&audioData, &audioLength);

      Os::Logger::instance().log(FAC_ACD, gACD_DEBUG, "ACDAudio::run - received %zd bytes from: %s\n",
                    audioLength, mUriString.data());

      // Now save the downloaded audio to a local file
      size_t writeLength;

      OsFile audioFile(mAudioPath);
      if (audioFile.open(OsFile::CREATE) != OS_SUCCESS) {
         Os::Logger::instance().log(FAC_ACD, PRI_ERR, "ACDAudio::run - "
                       "Unable to create audio file: %s", mAudioPath.data());
      }
      else {
         audioFile.write(audioData, audioLength, writeLength);
         audioFile.close();
      }
   }
   else {
      Os::Logger::instance().log(FAC_ACD, PRI_ERR, "ACDAudio::run - failed get from: %s", mUriString.data());
   }

   delete pGetRequest;

   return 0;
}
开发者ID:ATHLSolutions,项目名称:sipxecs,代码行数:43,代码来源:ACDAudio.cpp

示例2: execute

bool XmlRpcRequest::execute(XmlRpcResponse& response)
{
   bool result = false;

   // End of constructing the XML-RPC body
   mpRequestBody->append(END_PARAMS END_METHOD_CALL);

   if (OsSysLog::willLog(FAC_XMLRPC, PRI_INFO))
   {
      UtlString logString;
      ssize_t   logLength;
      mpRequestBody->getBytes(&logString, &logLength);
      if (logString.length() > XmlRpcBody::MAX_LOG)
      {
         logString.remove(XmlRpcBody::MAX_LOG);
         logString.append("\n...");
      }
      UtlString urlString;
      mUrl.toString(urlString);
      OsSysLog::add(FAC_XMLRPC, PRI_INFO,
                    "XmlRpcRequest::execute XML-RPC to '%s' request =\n%s",
                    urlString.data(),
                    logString.data());
   }

   mpHttpRequest->setContentLength(mpRequestBody->getLength());
   mpHttpRequest->setBody(mpRequestBody);
   mpRequestBody = NULL; // the HttpMessage now owns the request body

   // Create an empty response object and sent the built up request
   // to the XML-RPC server
   HttpMessage httpResponse;

   int statusCode = httpResponse.get(mUrl,*mpHttpRequest,XML_RPC_TIMEOUT,true /* persist conn */ );
   if (statusCode/100 == 2)
   {
      UtlString bodyString;
      ssize_t   bodyLength;

      httpResponse.getBody()->getBytes(&bodyString, &bodyLength);

      UtlString logString;
      if (bodyString.length() > XmlRpcBody::MAX_LOG)
      {
         logString.append(bodyString, 0, XmlRpcBody::MAX_LOG);
         logString.append("\n...");
      }
      else
      {
         logString = bodyString;
      }

      if (response.parseXmlRpcResponse(bodyString))
      {
         result = true;
         OsSysLog::add(FAC_XMLRPC, PRI_INFO,
                       "XmlRpcRequest::execute XML-RPC received valid response = \n%s",
                       logString.data());
      }
      else
      {
         OsSysLog::add(FAC_XMLRPC, PRI_ERR,
                       "XmlRpcRequest::execute XML-RPC received fault response = \n%s",
                       logString.data());
      }
   }
   else if (statusCode == -1)
   {
      response.setFault(XmlRpcResponse::ConnectionFailure, CONNECTION_FAILURE_FAULT_STRING);

      OsSysLog::add(FAC_XMLRPC, PRI_ERR,
                    "XmlRpcRequest::execute http connection failed");
   }
   else // some non-2xx HTTP response
   {
      UtlString statusText;

      httpResponse.getResponseStatusText(&statusText);
      response.setFault(XmlRpcResponse::HttpFailure, statusText.data());

      OsSysLog::add(FAC_XMLRPC, PRI_INFO,
                    "XmlRpcRequest::execute http request failed; status = %d %s",
                    statusCode, statusText.data());
   }

   return result;
}
开发者ID:LordGaav,项目名称:sipxecs,代码行数:87,代码来源:XmlRpcRequest.cpp


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