From 60015a1aee584a592ddb1bfec6a7b9e692a7abd8 Mon Sep 17 00:00:00 2001 From: gardners Date: Fri, 15 Feb 2013 17:34:39 +1030 Subject: [PATCH] keep HTTP server running when rhizome over http is disabled, but don't serve and rhizome requests. --- overlay.c | 7 +++---- rhizome_http.c | 26 ++++++++++++++------------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/overlay.c b/overlay.c index ceca7861..aeba6eab 100644 --- a/overlay.c +++ b/overlay.c @@ -133,10 +133,9 @@ schedule(&_sched_##X); } /* Rhizome http server needs to know which callback to attach to client sockets, so provide it here, along with the name to appear in time accounting statistics. */ - if (is_rhizome_http_enabled()) - rhizome_http_server_start(rhizome_server_parse_http_request, - "rhizome_server_parse_http_request", - RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX); + rhizome_http_server_start(rhizome_server_parse_http_request, + "rhizome_server_parse_http_request", + RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX); // start the dna helper if configured dna_helper_start(); diff --git a/rhizome_http.c b/rhizome_http.c index aa6db139..fc4746bd 100644 --- a/rhizome_http.c +++ b/rhizome_http.c @@ -546,16 +546,17 @@ int rhizome_server_parse_http_request(rhizome_http_request *r) rhizome_active_fetch_bytes_received(4) ); rhizome_server_simple_http_response(r, 200, temp); - } else if (strcmp(path, "/rhizome/groups") == 0) { - /* Return the list of known groups */ - rhizome_server_sql_query_http_response(r, "id", "groups", "from groups", 32, 1); - } else if (strcmp(path, "/rhizome/files") == 0) { - /* Return the list of known files */ - rhizome_server_sql_query_http_response(r, "id", "files", "from files", 32, 1); - } else if (strcmp(path, "/rhizome/bars") == 0) { - /* Return the list of known BARs */ - rhizome_server_sql_query_http_response(r, "bar", "manifests", "from manifests", 32, 0); - } else if (str_startswith(path, "/rhizome/file/", (const char **)&id)) { + } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/groups") == 0)) { + /* Return the list of known groups */ + rhizome_server_sql_query_http_response(r, "id", "groups", "from groups", 32, 1); + } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/files") == 0)) { + /* Return the list of known files */ + rhizome_server_sql_query_http_response(r, "id", "files", "from files", 32, 1); + } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/bars") == 0)) { + /* Return the list of known BARs */ + rhizome_server_sql_query_http_response(r, "bar", "manifests", "from manifests", 32, 0); + } else if (is_rhizome_http_enabled() + &&(str_startswith(path, "/rhizome/file/", (const char **)&id))) { /* Stream the specified payload */ if (!rhizome_str_is_file_hash(id)) { rhizome_server_simple_http_response(r, 400, "

Invalid payload ID

\r\n"); @@ -579,7 +580,8 @@ int rhizome_server_parse_http_request(rhizome_http_request *r) } if (blob) sqlite3_blob_close(blob); } - } else if (str_startswith(path, "/rhizome/manifest/", (const char **)&id)) { + } else if (is_rhizome_http_enabled()&& + (str_startswith(path, "/rhizome/manifest/", (const char **)&id))) { // TODO: Stream the specified manifest rhizome_server_simple_http_response(r, 500, "

Not implemented

\r\n"); } else if (str_startswith(path, "/rhizome/manifestbyprefix/", (const char **)&id)) { @@ -600,7 +602,7 @@ int rhizome_server_parse_http_request(rhizome_http_request *r) bid_high[RHIZOME_MANIFEST_ID_STRLEN]=0; DEBUGF("Looking for manifest between %s and %s", bid_low,bid_high); - + r->rowid = -1; sqlite3_blob *blob=NULL; r->sql_table="manifests";