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


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

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


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

示例1: handle_input

int ClientService::handle_input(ACE_HANDLE fd /* = ACE_INVALID_HANDLE */) {
	if ( fd != get_handle() ) {
		ND_DEBUG("[HTTP][Conn %07d] Received input for unmanaged handle.\n");
		return 0;
	}

	ssize_t recv_cnt;

	// ACE_Time_Value zeroTime(ACE_Time_Value::zero);
/*
	while ( (recv_cnt = sock_.recv(buffer_, buflen_)) > 0 ) {
		ND_DEBUG("[HTTP][Conn %07d] Received %d octets of request data.\n", _connectionNumber, recv_cnt);
		req_.addData(buffer_, recv_cnt);
	}

	int closeErr = errno;
	if (recv_cnt < 0 && closeErr != EWOULDBLOCK) {
		ND_DEBUG("[HTTP][Conn %07d] Connection closed to %s. %p.\n", _connectionNumber, peer_name_, "Reason");
		req_.clear();
		return -1;
	}
*/
	if ( (recv_cnt = sock_.recv(buffer_, buflen_)) < 1 ) {
		ND_DEBUG("[HTTP][Conn %07d] Connection closed to %s. %p.\n", _connectionNumber, peer_name_, "Reason");
		req_.clear();
		return -1;
	}

	ND_DEBUG("[HTTP][Conn %07d] Received %d octets of request data.\n", _connectionNumber, recv_cnt);
	req_.addData(buffer_, recv_cnt);

	// std::string reqStr(req_.getAsString());

	try {
		req_.parse();
	}
	catch (const nd_error& e) {
		ND_CRITICAL("[HTTP][Conn %07d] %s\n", _connectionNumber, e.what());
		req_.clear();
		return 0;
	}

	// ND_DEBUG("[HTTP][Conn %07d] Received %d-octet request:\n%s\n", _connectionNumber, req_.getRequestLength(), reqStr.c_str());

	if (req_.isComplete()) {
		HttpResponse response;

		httpManager::instance()->handleRequest(req_, response);

		string responseStr = response.makeClientStr((req_.getMethod() != HttpRequest::MethodHEAD));
		ND_DEBUG("[HTTP][Conn %07d] Sending response (%d %s, %s, %d octet contents).\n", _connectionNumber,
			response.getStatusCode(),
			response.getStatusStr().c_str(),
			response.getContentType().c_str(),
			response.getContent().length());

		sock_.send(responseStr.c_str(), responseStr.length());

		double ver = req_.getProtocolVersion();
		req_.clear();

		if ( ver == 1.0 ) {
			ND_DEBUG("[HTTP][Conn %07d] Closing HTTP 1.0 connection.\n", _connectionNumber);
			return -1;
		}
	}
	else {
		if ( req_.hasContent() )
			ND_DEBUG("[HTTP][Conn %07d] Received %d octets of %d expected, waiting for more.\n", _connectionNumber,
				req_.getContentLength(), req_.getReportedContentLength());
	}

	return 0;
}
开发者ID:E-LLP,项目名称:channel-emulator,代码行数:74,代码来源:ClientService.cpp


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