- 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> /// </value>
public IEnumerable<string> Names { public IEnumerable<string> Names {
get { get {
return new[] return new[] { "HEAD" };
{
"HEAD"
};
} }
} }

View File

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

View File

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

View File

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

View File

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