예제 #1
0
void
HTTPEngineSender::del(const URI& uri)
{
	const string path     = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str();
	const string full_uri = _engine_url.str() + "/" + path;
	SoupMessage* msg = soup_message_new(SOUP_METHOD_DELETE, full_uri.c_str());
	soup_session_send_message(_session, msg);
}
예제 #2
0
void
HTTPEngineSender::put(const URI&                  uri,
                      const Resource::Properties& properties,
                      Resource::Graph             ctx)
{
	const string path     = (uri.substr(0, 6) == "path:/") ? uri.substr(6) : uri.str();
	const string full_uri = _engine_url.str() + "/" + path;

	Sord::Model model(_world);
	for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i)
		model.add_statement(Sord::URI(_world, path),
		                    AtomRDF::atom_to_node(model, i->first),
		                    AtomRDF::atom_to_node(model, i->second));

	const string str = model.write_to_string("");
	SoupMessage* msg = soup_message_new(SOUP_METHOD_PUT, full_uri.c_str());
	assert(msg);
	soup_message_set_request(msg, "application/x-turtle", SOUP_MEMORY_COPY, str.c_str(), str.length());
	soup_session_send_message(_session, msg);
}
예제 #3
0
void
HTTPEngineSender::get(const URI& uri)
{
	if (!Raul::Path::is_path(uri) && uri.scheme() != "http") {
		LOG(warn) << "Ignoring GET of non-HTTP URI " << uri << endl;
		return;
	}

	const std::string request_uri = (Raul::Path::is_path(uri))
		?_engine_url.str() + "/patch" + uri.substr(uri.find("/"))
		: uri.str();
	cout << "Get " << request_uri << endl;
	LOG(debug) << "Get " << request_uri << endl;
	SoupMessage* msg = soup_message_new("GET", request_uri.c_str());
	HTTPClientReceiver::send(msg);
}