util: SegmentFetcher don't restart from segment 0 upon Nack

Change-Id: I167186961a82a4349fab5b4431c26a3fdb904bb8
refs: #3554
diff --git a/src/util/segment-fetcher.cpp b/src/util/segment-fetcher.cpp
index a9c0418..70ad632 100644
--- a/src/util/segment-fetcher.cpp
+++ b/src/util/segment-fetcher.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2013-2015 Regents of the University of California.
+ * Copyright (c) 2013-2016 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -178,9 +178,17 @@
   interest.refreshNonce();
   BOOST_ASSERT(interest.hasNonce());
 
+  bool isSegmentZeroExpected = true;
+  if (!interest.getName().empty()) {
+    name::Component lastComponent = interest.getName().get(-1);
+    isSegmentZeroExpected = !lastComponent.isSegment();
+  }
+
   m_face.expressInterest(interest,
-                         bind(&SegmentFetcher::afterSegmentReceived, this, _1, _2, true, self),
-                         bind(&SegmentFetcher::afterNackReceived, this, _1, _2, ++reExpressCount, self),
+                         bind(&SegmentFetcher::afterSegmentReceived, this, _1, _2,
+                              isSegmentZeroExpected, self),
+                         bind(&SegmentFetcher::afterNackReceived, this, _1, _2,
+                              ++reExpressCount, self),
                          bind(m_errorCallback, INTEREST_TIMEOUT, "Timeout"));
 }