Utilities/HttpServer.cs
changeset 402 0bad639907a3
parent 387 87093432c843
     1.1 --- a/Utilities/HttpServer.cs	Sun Jun 09 17:50:45 2013 +0000
     1.2 +++ b/Utilities/HttpServer.cs	Sun Jun 09 19:25:44 2013 +0000
     1.3 @@ -5,7 +5,7 @@
     1.4    file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.5   
     1.6  	Copyright (C) 2012 Prince Samuel <prince.samuel@gmail.com>
     1.7 -  Copyright (C) 2012 Michael Möller <mmoeller@openhardwaremonitor.org>
     1.8 +  Copyright (C) 2012-2013 Michael Möller <mmoeller@openhardwaremonitor.org>
     1.9  
    1.10  */
    1.11  
    1.12 @@ -37,6 +37,7 @@
    1.13  
    1.14        try {
    1.15          listener = new HttpListener();
    1.16 +        listener.IgnoreWriteExceptions = true;
    1.17        } catch (PlatformNotSupportedException) {
    1.18          listener = null;
    1.19        }
    1.20 @@ -156,10 +157,12 @@
    1.21                while ((len = stream.Read(buffer, 0, buffer.Length)) > 0) {
    1.22                  output.Write(buffer, 0, len);
    1.23                }
    1.24 -              output.Close();
    1.25 -            } catch (HttpListenerException) {
    1.26 +              output.Flush();
    1.27 +              output.Close();              
    1.28 +              response.Close();
    1.29 +            } catch (HttpListenerException) { 
    1.30 +            } catch (InvalidOperationException) { 
    1.31              }
    1.32 -            response.Close();
    1.33              return;
    1.34            }          
    1.35          }