SSPCPP-616 - clean up concatenated string literals
[shibboleth/cpp-sp.git] / shibsp / handler / impl / DiscoveryFeed.cpp
index 72e87f2..f0f3514 100644 (file)
@@ -111,7 +111,7 @@ namespace shibsp {
 };
 
 DiscoveryFeed::DiscoveryFeed(const DOMElement* e, const char* appId)
-    : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT".DiscoveryFeed"), &g_Blocker), m_cacheToClient(false)
+    : AbstractHandler(e, Category::getInstance(SHIBSP_LOGCAT ".DiscoveryFeed"), &g_Blocker), m_cacheToClient(false)
 {
     pair<bool,const char*> prop = getString("Location");
     if (!prop.first)
@@ -127,7 +127,7 @@ DiscoveryFeed::DiscoveryFeed(const DOMElement* e, const char* appId)
         prop = getString("dir");
         if (prop.first)
             m_dir = prop.second;
-        XMLToolingConfig::getConfig().getPathResolver()->resolve(m_dir, PathResolver::XMLTOOLING_RUN_FILE);
+        XMLToolingConfig::getConfig().getPathResolver()->resolve(m_dir, PathResolver::XMLTOOLING_CACHE_FILE);
         m_log.info("feed files will be cached in %s", m_dir.c_str());
 #ifndef SHIBSP_LITE
         m_feedLock.reset(Mutex::create());
@@ -143,7 +143,7 @@ DiscoveryFeed::~DiscoveryFeed()
         // Anything left will be orphaned, but that shouldn't happen too often.
         time_t now = time(nullptr);
         while (!m_feedQueue.empty() && now - m_feedQueue.front().second > 120) {
-            string fname = m_dir + '/' + m_feedQueue.front().first;
+            string fname = m_dir + '/' + m_feedQueue.front().first + ".json";
             remove(fname.c_str());
             m_feedQueue.pop();
         }
@@ -171,7 +171,7 @@ pair<bool,long> DiscoveryFeed::run(SPRequest& request, bool isHandler) const
                         string etag = '"' + s + '"';
                         request.setResponseHeader("ETag", etag.c_str());
                     }
-                    request.setContentType("application/json");
+                    request.setContentType("application/json; charset=UTF-8");
                     return make_pair(true, request.sendResponse(buf));
                 }
             }
@@ -197,7 +197,7 @@ pair<bool,long> DiscoveryFeed::run(SPRequest& request, bool isHandler) const
                 }
                 if (out["feed"].string()) {
                     istringstream buf(out["feed"].string());
-                    request.setContentType("application/json");
+                    request.setContentType("application/json; charset=UTF-8");
                     return make_pair(true, request.sendResponse(buf));
                 }
                 throw ConfigurationException("Discovery feed was empty.");
@@ -223,7 +223,7 @@ pair<bool,long> DiscoveryFeed::run(SPRequest& request, bool isHandler) const
             string etag = '"' + s + '"';
             request.setResponseHeader("ETag", etag.c_str());
         }
-        request.setContentType("application/json");
+        request.setContentType("application/json; charset=UTF-8");
         return make_pair(true, request.sendResponse(feed));
     }
     catch (std::exception& ex) {
@@ -295,7 +295,7 @@ void DiscoveryFeed::feedToFile(const Application& application, string& cacheTag)
 
     // Clean up any old files.
     while (m_feedQueue.size() > 1 && (now - m_feedQueue.front().second > 120)) {
-        string fname = m_dir + '/' + m_feedQueue.front().first;
+        string fname = m_dir + '/' + m_feedQueue.front().first + ".json";
         remove(fname.c_str());
         m_feedQueue.pop();
     }