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


C++ HttpResponse::SetBody方法代码示例

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


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

示例1: HttpResponse

HttpResponse * 
EHS::RouteRequest ( HttpRequest * ipoHttpRequest ///< request info for service
	)
{

	// get the next path from the URI
	std::string sNextPathPart = GetNextPathPart ( ipoHttpRequest->sUri );


	EHS_TRACE ( "Info: Trying to route: '%s'\n", sNextPathPart.c_str ( ) );


	// if there is no more path, call HandleRequest on this EHS object with
	//   whatever's left - or if we're not routing
	if ( sNextPathPart.empty ( ) ||
		 m_oEHSServerParameters.find ( "norouterequest" ) !=
		 m_oEHSServerParameters.end ( ) ) {

		// create an HttpRespose object for the client
		HttpResponse * poHttpResponse = 
			new HttpResponse ( ipoHttpRequest->m_nRequestId,
							   ipoHttpRequest->m_poSourceEHSConnection );
		
		// get the actual response and return code
		poHttpResponse->m_nResponseCode = 
			HandleRequest ( ipoHttpRequest, poHttpResponse );

		return poHttpResponse;

	}

	// if the path exists, check it against the map of EHSs
	if ( oEHSMap [ sNextPathPart ] ) {

		// if it exists, call RouteRequest with that EHS and the
		//   new shortened path

		return oEHSMap [ sNextPathPart ]->RouteRequest ( ipoHttpRequest );

	}
	// if it doesn't exist, send an error back up saying resource doesn't exist
	else {

		
		EHS_TRACE ( "Info: Routing failed.  Most likely caused by an invalid URL, not internal error\n" );


		// send back a 404 response
		HttpResponse * poHttpResponse = new HttpResponse ( ipoHttpRequest->m_nRequestId,
														   ipoHttpRequest->m_poSourceEHSConnection );

		poHttpResponse->m_nResponseCode = HTTPRESPONSECODE_404_NOTFOUND;
		poHttpResponse->SetBody ( "404 - Not Found", strlen ( "404 - Not Found" ) );

		return poHttpResponse;
		
	}

}
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:59,代码来源:ehs.cpp

示例2: msg

 HttpResponse *HandleThreadException(ehs_threadid_t, HttpRequest *request, exception &ex)
 {
     HttpResponse *ret = NULL;
     string msg(ex.what());
     cerr << "##################### Catched " << msg << endl;
     cerr << "request: " << hex << request << dec << endl;
     tracing::exception *btx =
         dynamic_cast<tracing::exception*>(&ex);
     if (NULL != btx) {
         string tmsg = btx->where();
         cerr << "Backtrace:" << endl << tmsg;
         if (0 != msg.compare("fatal")) {
             ret = HttpResponse::Error(HTTPRESPONSECODE_500_INTERNALSERVERERROR, request);
             string body(ret->GetBody());
             tmsg.insert(0, "<br>\n<pre>").append(msg).append("</pre><p><a href=\"/\">Back to main page</a>");
             body.insert(body.find("</body>"), tmsg);
             ret->SetBody(body.c_str(), body.length());
         }
     }
     return ret;
 }
开发者ID:FransUrbo,项目名称:EHS,代码行数:21,代码来源:ehs_wsgate.cpp


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