From fd5b9805deb5a12f1cd5f7571ee9b7728f3ddf8b Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Tue, 10 Jan 2017 12:34:43 +0100
Subject: [PATCH] Fixed favicon.ico

---
 src/output/output_http_internal.cpp | 40 +++++++++++++++++++----------
 src/output/output_http_internal.h   |  1 +
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp
index fd7ce399..0f6fcb7d 100644
--- a/src/output/output_http_internal.cpp
+++ b/src/output/output_http_internal.cpp
@@ -32,6 +32,11 @@ namespace Mist {
   }
   
   void OutHTTP::onFail(){
+    // send logo icon
+    if (H.url.length() > 4 && H.url.substr(H.url.length() - 4, 4) == ".ico"){
+      sendIcon();
+      return;
+    }
     INFO_MSG("Failing: %s", H.url.c_str());
     if (H.url.size() >= 3 && H.url.substr(H.url.size() - 3) == ".js"){
       if (H.url.size() >= 5 && H.url.substr(0, 5) == "/json"){
@@ -250,20 +255,7 @@ namespace Mist {
     }
     // send logo icon
     if (H.url.length() > 4 && H.url.substr(H.url.length() - 4, 4) == ".ico"){
-      H.Clean();
-      #include "../icon.h"
-      H.SetHeader("Content-Type", "image/x-icon");
-      H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
-      H.SetHeader("Content-Length", icon_len);
-      H.setCORSHeaders();
-      if(method == "OPTIONS" || method == "HEAD"){
-        H.SendResponse("200", "OK", myConn);
-        H.Clean();
-        return;
-      }
-      H.SendResponse("200", "OK", myConn);
-      myConn.SendNow((const char*)icon_data, icon_len);
-      H.Clean();
+      sendIcon();
       return;
     }
     
@@ -618,4 +610,24 @@ namespace Mist {
       return;
     }
   }
+
+  void OutHTTP::sendIcon(){
+    std::string method = H.method;
+    H.Clean();
+    #include "../icon.h"
+    H.SetHeader("Content-Type", "image/x-icon");
+    H.SetHeader("Server", "MistServer/" PACKAGE_VERSION);
+    H.SetHeader("Content-Length", icon_len);
+    H.setCORSHeaders();
+    if(method == "OPTIONS" || method == "HEAD"){
+      H.SendResponse("200", "OK", myConn);
+      H.Clean();
+      return;
+    }
+    H.SendResponse("200", "OK", myConn);
+    myConn.SendNow((const char*)icon_data, icon_len);
+    H.Clean();
+  }
+
 }
+
diff --git a/src/output/output_http_internal.h b/src/output/output_http_internal.h
index 479d37a4..5cda9bb3 100644
--- a/src/output/output_http_internal.h
+++ b/src/output/output_http_internal.h
@@ -11,6 +11,7 @@ namespace Mist {
       virtual void onFail();
       void onHTTP();
       bool isReadyForPlay();
+      void sendIcon();
   };
 }