Example #1
0
bool RESTHandler::build_message(Poco::Net::HTTPServerRequest &request, Poco::Net::HTMLForm &form, Poco::URI &url,
                                zmqpp::message &msg) {

    Json::Value root;
    bool ok = false;
    /// Find 'args' param in query or as POST body
    if (form.has("args")) {
        ok = reader.parse(form.get("args"), root);
    } else if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_POST) {
        ok = reader.parse(request.stream(), root);
    }
    if (!ok || !root.isArray()) {
        return false;
    }
    if (verbose) {
        std::clog << "0\t" << url.getPath().substr(1) << std::endl;
    }
    /// Get service name as path without leading slash
    msg << url.getPath().substr(1);
    for (size_t i = 0; i < root.size(); ++i) {
        auto val = root.get(i, "");
        if (!verbose)
            msg << (val.isString() ? root.get(i, "").asString() : val.toStyledString());
        else {
            std::string s = (val.isString() ? root.get(i, "").asString() : val.toStyledString());
            msg << s;
            std::clog << (i + 1) << '\t' << s << std::endl;
        }
    }
    return true;
}
Example #2
0
void HTMLFormWrapper::getField(const v8::FunctionCallbackInfo<v8::Value>& args)
{
	if (args.Length() < 1) return;
	Poco::Net::HTMLForm* pForm = Wrapper::unwrapNative<Poco::Net::HTMLForm>(args);
	std::string name = toString(args[0]);
	std::string deflt;
	if (args.Length() > 1) deflt = toString(args[1]);
	std::string value = pForm->get(name, deflt);
	returnString(args, value);
}
Example #3
0
bool TrafficPage::handleForm(Poco::Net::HTMLForm& form, Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse &)
{
    _local = form.has("local");
    _all = form.has("all");
    if (form.has("filter")) {
        _group = form.get("filter");
        if (_group == "IP") {
            _group = "traffic.ip";
        }
    }
    return false;
}
void Service::processQuery(const Poco::Net::HTMLForm & params, ReadBuffer & body, WriteBuffer & out)
{
	if (is_cancelled)
		throw Exception{"RemoteQueryExecutor service terminated", ErrorCodes::ABORTED};

	std::string query = params.get("query");

	bool flag = true;

	try
	{
		(void) executeQuery(query, context, true);
	}
	catch (...)
	{
		tryLogCurrentException(__PRETTY_FUNCTION__);
		flag = false;
	}

	writeBinary(flag, out);
	out.next();
}