Exemplo n.º 1
0
bool http_client::handle(void)
{
	const char* cmd = http_hdr_req_param(hdr_req_, "cmd");
	if (cmd == NULL || *cmd == 0) {
		//logger_error("cmd null");
		acl::string dummy;
		do_reply(400, "none", dummy, false);
		if (hdr_req_->hdr.keep_alive)
			wait();
		else
			acl_aio_iocp_close(conn_);
		return true;
	}

#define EQ !strcasecmp

	int i;

	for (i = 0; handlers[i].cmd != NULL; i++) {
		if (EQ(cmd, handlers[i].cmd))
			break;
	}

	if (handlers[i].handler == NULL) {
		logger_warn("invalid cmd=%s", cmd);
		acl::string dummy;
		do_reply(400, "unknown", dummy, false);
		if (hdr_req_->hdr.keep_alive)
			wait();
		else
			acl_aio_iocp_close(conn_);
		return true;
	}

	if ((this->*handlers[i].handler)())
		return true;

	acl_aio_iocp_close(conn_);
	return false;
}
Exemplo n.º 2
0
const char* http_client::request_param(const char* name) const
{
	if (!is_request_ && hdr_req_)
		return http_hdr_req_param(hdr_req_, name);
	return NULL;
}