keep HTTP server running when rhizome over http is disabled, but

don't serve and rhizome requests.
This commit is contained in:
gardners 2013-02-15 17:34:39 +10:30 committed by Jeremy Lakeman
parent 506ceea309
commit 60015a1aee
2 changed files with 17 additions and 16 deletions

View File

@ -133,7 +133,6 @@ schedule(&_sched_##X); }
/* Rhizome http server needs to know which callback to attach /* Rhizome http server needs to know which callback to attach
to client sockets, so provide it here, along with the name to to client sockets, so provide it here, along with the name to
appear in time accounting statistics. */ appear in time accounting statistics. */
if (is_rhizome_http_enabled())
rhizome_http_server_start(rhizome_server_parse_http_request, rhizome_http_server_start(rhizome_server_parse_http_request,
"rhizome_server_parse_http_request", "rhizome_server_parse_http_request",
RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX); RHIZOME_HTTP_PORT,RHIZOME_HTTP_PORT_MAX);

View File

@ -546,16 +546,17 @@ int rhizome_server_parse_http_request(rhizome_http_request *r)
rhizome_active_fetch_bytes_received(4) rhizome_active_fetch_bytes_received(4)
); );
rhizome_server_simple_http_response(r, 200, temp); rhizome_server_simple_http_response(r, 200, temp);
} else if (strcmp(path, "/rhizome/groups") == 0) { } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/groups") == 0)) {
/* Return the list of known groups */ /* Return the list of known groups */
rhizome_server_sql_query_http_response(r, "id", "groups", "from groups", 32, 1); rhizome_server_sql_query_http_response(r, "id", "groups", "from groups", 32, 1);
} else if (strcmp(path, "/rhizome/files") == 0) { } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/files") == 0)) {
/* Return the list of known files */ /* Return the list of known files */
rhizome_server_sql_query_http_response(r, "id", "files", "from files", 32, 1); rhizome_server_sql_query_http_response(r, "id", "files", "from files", 32, 1);
} else if (strcmp(path, "/rhizome/bars") == 0) { } else if (is_rhizome_http_enabled()&&(strcmp(path, "/rhizome/bars") == 0)) {
/* Return the list of known BARs */ /* Return the list of known BARs */
rhizome_server_sql_query_http_response(r, "bar", "manifests", "from manifests", 32, 0); 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()
&&(str_startswith(path, "/rhizome/file/", (const char **)&id))) {
/* Stream the specified payload */ /* Stream the specified payload */
if (!rhizome_str_is_file_hash(id)) { if (!rhizome_str_is_file_hash(id)) {
rhizome_server_simple_http_response(r, 400, "<html><h1>Invalid payload ID</h1></html>\r\n"); rhizome_server_simple_http_response(r, 400, "<html><h1>Invalid payload ID</h1></html>\r\n");
@ -579,7 +580,8 @@ int rhizome_server_parse_http_request(rhizome_http_request *r)
} }
if (blob) sqlite3_blob_close(blob); 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 // TODO: Stream the specified manifest
rhizome_server_simple_http_response(r, 500, "<html><h1>Not implemented</h1></html>\r\n"); rhizome_server_simple_http_response(r, 500, "<html><h1>Not implemented</h1></html>\r\n");
} else if (str_startswith(path, "/rhizome/manifestbyprefix/", (const char **)&id)) { } else if (str_startswith(path, "/rhizome/manifestbyprefix/", (const char **)&id)) {