From 57403527a9df182be40e8c3004a6dcc64322ed33 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 28 Jan 2013 11:26:58 +0100 Subject: [PATCH] issue #374 --- CHANGELOG | 3 ++ UnitTests/HttpInterface/api-admin-spec.rb | 40 ++++++++++++++++++++++- lib/HttpServer/PathHandler.cpp | 5 +-- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ad228d4557..3cc6950830 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,9 @@ v1.2.alpha (XXXX-XX-XX) ----------------------- +* issue #374: prevent endless redirects when calling admin interface with + unexpected URLs + * issue #373: TRAVERSE() `trackPaths` option does not work. Instead `paths` does work * issue #358: added support for CORS diff --git a/UnitTests/HttpInterface/api-admin-spec.rb b/UnitTests/HttpInterface/api-admin-spec.rb index d82bb7a919..0ed8cbd6ce 100644 --- a/UnitTests/HttpInterface/api-admin-spec.rb +++ b/UnitTests/HttpInterface/api-admin-spec.rb @@ -7,11 +7,17 @@ describe ArangoDB do context "dealing with the admin interface:" do + before do + # load the most current routing information + cmd = "/_admin/routing/reload" + doc = ArangoDB.log_get("admin-interface-get", cmd) + end + ################################################################################ ## check whether admin interface is accessible ################################################################################ - it "checks whether the admin interface is available at /_admin/html" do + it "checks whether the admin interface is available at /_admin/html/index.html" do cmd = "/_admin/html/index.html" doc = ArangoDB.log_get("admin-interface-get", cmd, :format => :plain) @@ -19,7 +25,39 @@ describe ArangoDB do doc.code.should eq(200) # check whether HTML result contains expected title doc.response.body.should include("ArangoDB - WebAdmin") + end + it "checks whether the admin interface is available at /_admin/html" do + cmd = "/_admin/html" + begin + doc = ArangoDB.log_get("admin-interface-get", cmd, :format => :plain, :no_follow => true) + rescue HTTParty::RedirectionTooDeep => e + # check response code + e.response.code.should eq("301") + e.response.header['location'].should eq("/_admin/html/index.html") + end + end + + it "checks whether the admin interface is available at /_admin/html/" do + cmd = "/_admin/html/" + begin + doc = ArangoDB.log_get("admin-interface-get", cmd, :format => :plain, :no_follow => true) + rescue HTTParty::RedirectionTooDeep => e + # check response code + e.response.code.should eq("301") + e.response.header['location'].should eq("/_admin/html/index.html") + end + end + + it "checks whether the admin interface is available at /" do + cmd = "/" + begin + doc = ArangoDB.log_get("admin-interface-get", cmd, :format => :plain, :no_follow => true) + rescue HTTParty::RedirectionTooDeep => e + # check response code + e.response.code.should eq("301") + e.response.header['location'].should eq("/_admin/html/index.html") + end end end diff --git a/lib/HttpServer/PathHandler.cpp b/lib/HttpServer/PathHandler.cpp index 448c87dcd0..c6017d222d 100644 --- a/lib/HttpServer/PathHandler.cpp +++ b/lib/HttpServer/PathHandler.cpp @@ -71,10 +71,11 @@ namespace triagens { if (names.empty() && ! defaultFile.empty()) { string url = _request->requestPath(); - + if (! url.empty() && url[url.size() - 1] != '/') { - url += "/" + defaultFile; + url += '/'; } + url += defaultFile; _response = createResponse(HttpResponse::MOVED_PERMANENTLY);