From ffbd2a0f563a0704361e17720cf11d9130341dc1 Mon Sep 17 00:00:00 2001
From: Teemu Ikonen <tpikonen@gmail.com>
Date: Sun, 6 Jan 2019 15:34:22 +0200
Subject: [PATCH] Fix 'configure --enable-restbed-old-api'.

(It would probably be enough to just include config.h, but now the
intention is clearer)

Change-Id: Ia427d940b5b9e94b6ba174fc38e9d638d507ae45
Reviewed-by: Philippe Gorley <philippe.gorley@savoirfairelinux.com>
---
 configure.ac                  | 2 +-
 src/ringdht/namedirectory.cpp | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8fbc282762..74b86bb0b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -430,7 +430,7 @@ AC_ARG_WITH([restcpp],
     AS_HELP_STRING([--with-restcpp], [enable rest support with C++]))
 AC_ARG_ENABLE([restbed_old_api], AS_HELP_STRING([--enable-restbed-old-api], [Use the old restbed API]))
 AS_IF([test "x$enable_restbed_old_api" = "xyes"], [
-  AC_DEFINE([RESTBED_OLD_API], [], [Defined if you use the old restbed API])
+  AC_DEFINE([RESTBED_OLD_API], [1], [Defined if you use the old restbed API])
 ])
 
 AS_IF([test "x$enable_ringns" != "xno" || test "x$with_restcpp" = "xyes"], [
diff --git a/src/ringdht/namedirectory.cpp b/src/ringdht/namedirectory.cpp
index ed918ba1f2..2c4d5a7776 100644
--- a/src/ringdht/namedirectory.cpp
+++ b/src/ringdht/namedirectory.cpp
@@ -21,6 +21,7 @@
 #include "string_utils.h"
 #include "thread_pool.h"
 #include "fileutils.h"
+#include "config.h"
 
 #include <msgpack.hpp>
 #include <json/json.h>
@@ -93,10 +94,11 @@ NameDirectory& NameDirectory::instance(const std::string& server)
 size_t getContentLength(restbed::Response& reply)
 {
     size_t length = 0;
-#ifndef RESTBED_OLD_API
-    length =
-#endif
+#ifdef RESTBED_OLD_API
     reply.get_header("Content-Length", length);
+#else
+    length = reply.get_header("Content-Length", 0);
+#endif
     return length;
 }
 
-- 
GitLab