- add: webdav -logging

- fix: webdav - endimpersonation before setting result
This commit is contained in:
Michael Vesely 2017-03-02 15:46:40 +01:00
parent 43d08f5b1f
commit 45d7b44621
5 changed files with 22 additions and 16 deletions

View File

@ -19,10 +19,7 @@ namespace WebDAVSharp.Server.MethodHandlers {
/// </value>
public IEnumerable<string> Names {
get {
return new[]
{
"HEAD"
};
return new[] { "HEAD" };
}
}

View File

@ -14,10 +14,7 @@ namespace WebDAVSharp.Server.MethodHandlers {
/// </summary>
public IEnumerable<string> Names {
get {
return new[]
{
"OPTIONS"
};
return new[] { "OPTIONS" };
}
}

View File

@ -28,10 +28,7 @@ namespace WebDAVSharp.Server.MethodHandlers {
/// </value>
public IEnumerable<string> Names {
get {
return new[]
{
"PROPFIND"
};
return new[] { "PROPFIND" };
}
}

View File

@ -61,11 +61,13 @@
<AssemblyOriginatorKeyFile>..\Lasse V. Karlsen.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Common.Logging">
<HintPath>packages\Common.Logging.2.2.0\lib\net40\Common.Logging.dll</HintPath>
<Reference Include="Common.Logging, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
<HintPath>..\..\..\Train2B\packages\Common.Logging.2.2.0\lib\net40\Common.Logging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Common.Logging.Core">
<HintPath>packages\Common.Logging.Core.2.2.0\lib\net40\Common.Logging.Core.dll</HintPath>
<Reference Include="Common.Logging.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=af08829b84f0328e, processorArchitecture=MSIL">
<HintPath>..\..\..\Train2B\packages\Common.Logging.Core.2.2.0\lib\net40\Common.Logging.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />

View File

@ -11,6 +11,7 @@ using WebDAVSharp.Server.Exceptions;
using WebDAVSharp.Server.MethodHandlers;
using WebDAVSharp.Server.Stores;
using System.Web;
using System.Diagnostics;
namespace WebDAVSharp.Server {
/// <summary>
@ -234,6 +235,7 @@ namespace WebDAVSharp.Server {
Thread.SetData(Thread.GetNamedDataSlot(HttpUser), context.User.Identity);
_log.Info(context.Request.HttpMethod + " " + fileName);
Trace.WriteLine($"\nWebDAV - {context.Request.HttpMethod} - {fileName} - {context.User.Identity.AuthenticationType}: {context.User.Identity.Name}"); //
try {
try {
string method = context.Request.HttpMethod;
@ -271,6 +273,7 @@ namespace WebDAVSharp.Server {
}
catch (WebDavException ex) {
_log.Warn(ex.StatusCode + " " + ex.Message);
Trace.WriteLine($"WebDAV ex - {ex.StatusCode} - {ex.StatusDescription} : {ex.Message}"); //
context.Response.StatusCode = ex.StatusCode;
context.Response.StatusDescription = ex.StatusDescription;
if (ex.Message != context.Response.StatusDescription) {
@ -283,6 +286,16 @@ namespace WebDAVSharp.Server {
}
finally {
_log.Info(context.Response.StatusCode + " " + context.Response.StatusDescription + ": " + context.Request.HttpMethod + " " + fileName);
string headers = "";
try {
foreach (var key in context.Response.Headers.AllKeys) {
headers += $"\t{key}: {context.Response.Headers[key]}\n";
}
}
catch (Exception ex) {
Trace.WriteLine(ex);
}
Trace.WriteLine("WebDAV - " + context.Response.StatusCode + " " + context.Response.StatusDescription + ": " + context.Request.HttpMethod + " " + fileName + "Headers:\n" + headers);
}
}
}