summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/client/HTTPClientReceiver.cpp10
-rw-r--r--src/client/HTTPEngineSender.cpp18
-rw-r--r--src/engine/HTTPClientSender.cpp11
-rw-r--r--src/engine/HTTPEngineReceiver.cpp18
-rw-r--r--src/serialisation/Serialiser.cpp5
5 files changed, 41 insertions, 21 deletions
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 2b9b2cce..ce4c2384 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -190,15 +190,17 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
Glib::ustring(msg->response_body->data), me->_url);
}
- } else if (path == "/patch") {
+ } else if (path.substr(0, 6) == "/patch") {
if (msg->response_body->data == NULL) {
LOG(error) << "Empty response" << endl;
} else {
Glib::Mutex::Lock lock(me->_mutex);
me->_target->response_ok(0);
- me->_world->parser()->parse_string(me->_world, me->_target.get(),
- Glib::ustring(msg->response_body->data),
- Glib::ustring("/patch/"));
+ me->_world->parser()->parse_string(
+ me->_world,
+ me->_target.get(),
+ Glib::ustring(msg->response_body->data),
+ path);
}
} else if (path == "/stream") {
diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp
index 98c43a12..ceb60162 100644
--- a/src/client/HTTPEngineSender.cpp
+++ b/src/client/HTTPEngineSender.cpp
@@ -106,7 +106,7 @@ HTTPEngineSender::delta(const Raul::URI& path,
const Resource::Properties& remove,
const Resource::Properties& add)
{
- warn << "FIXME: HTTP DELTA" << endl;
+ LOG(warn) << "TODO: HTTP delta" << endl;
}
void
@@ -133,18 +133,21 @@ void
HTTPEngineSender::connect(const Path& src_port_path,
const Path& dst_port_path)
{
+ LOG(warn) << "TODO: HTTP connect" << endl;
}
void
HTTPEngineSender::disconnect(const Path& src_port_path,
const Path& dst_port_path)
{
+ LOG(warn) << "TODO: HTTP disconnect" << endl;
}
void
HTTPEngineSender::disconnect_all(const Path& parent_patch_path,
const Path& path)
{
+ LOG(warn) << "TODO: HTTP disconnect_all" << endl;
}
void
@@ -169,8 +172,17 @@ HTTPEngineSender::ping()
void
HTTPEngineSender::get(const URI& uri)
{
- LOG(debug) << "Get " << _engine_url << endl;
- SoupMessage* msg = soup_message_new("GET", uri.c_str());
+ 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);
}
diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp
index 6d91a2c0..83d09b97 100644
--- a/src/engine/HTTPClientSender.cpp
+++ b/src/engine/HTTPClientSender.cpp
@@ -53,13 +53,16 @@ HTTPClientSender::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 = _url + "/" + path;
+ const std::string request_uri = (Raul::Path::is_path(uri))
+ ? _url + "/patch" + uri.substr(uri.find("/"))
+ : uri.str();
+
Sord::Model model(*_engine.world()->rdf_world());
- for (Resource::Properties::const_iterator i = properties.begin(); i != properties.end(); ++i)
+ for (Resource::Properties::const_iterator i = properties.begin();
+ i != properties.end(); ++i)
model.add_statement(
- Sord::URI(*_engine.world()->rdf_world(), path),
+ Sord::URI(*_engine.world()->rdf_world(), request_uri),
AtomRDF::atom_to_node(model, i->first.str()),
AtomRDF::atom_to_node(model, i->second));
diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp
index b0bf2f4d..910be584 100644
--- a/src/engine/HTTPEngineReceiver.cpp
+++ b/src/engine/HTTPEngineReceiver.cpp
@@ -89,24 +89,25 @@ HTTPEngineReceiver::message_callback(SoupServer* server,
SoupClientContext* client,
void* data)
{
- #if 0
HTTPEngineReceiver* me = (HTTPEngineReceiver*)data;
+ using namespace Ingen::Shared;
+
SharedPtr<Store> store = me->_engine.world()->store();
if (!store) {
- soup_message_set_status (msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
+ soup_message_set_status(msg, SOUP_STATUS_INTERNAL_SERVER_ERROR);
return;
}
string path = path_str;
- if (path[path.length()-1] == '/') {
+ if (path[path.length() - 1] == '/') {
path = path.substr(0, path.length()-1);
}
SharedPtr<Serialiser> serialiser = me->_engine.world()->serialiser();
- const string base_uri = "path:/";
- const char* mime_type = "text/plain";
+ const string base_uri = "path:/";
+ const char* mime_type = "text/plain";
// Special GET paths
if (msg->method == SOUP_METHOD_GET) {
@@ -121,6 +122,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server,
} else if (msg->method == SOUP_METHOD_GET && path.substr(0, 8) == "/plugins") {
// FIXME: kludge
+ #if 0
me->get("ingen:plugins");
me->_receive_thread->whip();
@@ -131,10 +133,13 @@ HTTPEngineReceiver::message_callback(SoupServer* server,
const string r = serialiser->finish();
soup_message_set_status(msg, SOUP_STATUS_OK);
soup_message_set_response(msg, mime_type, SOUP_MEMORY_COPY, r.c_str(), r.length());
+ #endif
return;
} else if (path.substr(0, 6) == "/patch") {
path = '/' + path.substr(6);
+ if (path.substr(0, 2) == "//")
+ path = path.substr(1);
} else if (path.substr(0, 7) == "/stream") {
HTTPClientSender* client = new HTTPClientSender(me->_engine);
@@ -152,7 +157,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server,
if (!Path::is_valid(path)) {
LOG(error) << "Bad HTTP path: " << path << endl;
- soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST);
+ soup_message_set_status(msg, SOUP_STATUS_BAD_REQUEST);
const string& err = (boost::format("Bad path: %1%") % path).str();
soup_message_set_response(msg, "text/plain", SOUP_MEMORY_COPY,
err.c_str(), err.length());
@@ -209,7 +214,6 @@ HTTPEngineReceiver::message_callback(SoupServer* server,
} else {
soup_message_set_status(msg, SOUP_STATUS_NOT_IMPLEMENTED);
}
- #endif
}
/** Override the semaphore driven _run method of QueuedEngineInterface
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index 37d80e0d..1eb76344 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -266,7 +266,7 @@ Sord::Node
Serialiser::path_rdf_node(const Path& path)
{
assert(_model);
- assert(path.is_child_of(_root_path));
+ assert(path == _root_path || path.is_child_of(_root_path));
const Path rel_path(path.relative_to_base(_root_path));
return Sord::URI(_model->world(), rel_path.chop_scheme().substr(1));
}
@@ -323,8 +323,7 @@ Serialiser::serialise_patch(SharedPtr<Patch> patch, const Sord::Node& patch_id)
if (s == patch->properties().end()
|| !s->second.type() == Atom::STRING
|| !Symbol::is_valid(s->second.get_string())) {
- const string path = Glib::filename_from_uri(_model->base_uri().to_c_string());
- symbol = Glib::path_get_basename(path);
+ symbol = Glib::path_get_basename(_model->base_uri().to_c_string());
symbol = Symbol::symbolify(symbol.substr(0, symbol.find('.')));
_model->add_statement(
patch_id,