Added additional exception handling to the http server.
authormoel.mich
Sun, 09 Jun 2013 19:25:44 +0000
changeset 4020bad639907a3
parent 401 c37f2b5ee55b
child 403 c540cf36b7ce
Added additional exception handling to the http server.
Properties/AssemblyVersion.cs
Utilities/HttpServer.cs
     1.1 --- a/Properties/AssemblyVersion.cs	Sun Jun 09 17:50:45 2013 +0000
     1.2 +++ b/Properties/AssemblyVersion.cs	Sun Jun 09 19:25:44 2013 +0000
     1.3 @@ -10,5 +10,5 @@
     1.4  
     1.5  using System.Reflection;
     1.6  
     1.7 -[assembly: AssemblyVersion("0.5.1.14")]
     1.8 -[assembly: AssemblyInformationalVersion("0.5.1.14 Alpha")]
     1.9 \ No newline at end of file
    1.10 +[assembly: AssemblyVersion("0.5.1.15")]
    1.11 +[assembly: AssemblyInformationalVersion("0.5.1.15 Alpha")]
    1.12 \ No newline at end of file
     2.1 --- a/Utilities/HttpServer.cs	Sun Jun 09 17:50:45 2013 +0000
     2.2 +++ b/Utilities/HttpServer.cs	Sun Jun 09 19:25:44 2013 +0000
     2.3 @@ -5,7 +5,7 @@
     2.4    file, You can obtain one at http://mozilla.org/MPL/2.0/.
     2.5   
     2.6  	Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
     2.7 -  Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     2.8 +  Copyright (C) 2012-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
     2.9  
    2.10  */
    2.11  
    2.12 @@ -37,6 +37,7 @@
    2.13  
    2.14        try {
    2.15          listener = new HttpListener();
    2.16 +        listener.IgnoreWriteExceptions = true;
    2.17        } catch (PlatformNotSupportedException) {
    2.18          listener = null;
    2.19        }
    2.20 @@ -156,10 +157,12 @@
    2.21                while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) {
    2.22                  output.Write(buffer, 0, len);
    2.23                }
    2.24 -              output.Close();
    2.25 -            } catch (HttpListenerException) {
    2.26 +              output.Flush();
    2.27 +              output.Close();              
    2.28 +              response.Close();
    2.29 +            } catch (HttpListenerException) { 
    2.30 +            } catch (InvalidOperationException) { 
    2.31              }
    2.32 -            response.Close();
    2.33              return;
    2.34            }          
    2.35          }