WIP: find, and harden against User null issue
This commit is contained in:
parent
861f23d29c
commit
04107c8cb6
|
@ -36,17 +36,17 @@ namespace WebDAVSharp.Server
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WebDavServer" /> class.
|
||||
/// </summary>
|
||||
/// <param name="store">The
|
||||
/// <param name="store">The
|
||||
/// <see cref="IWebDavStore" /> store object that will provide
|
||||
/// collections and documents for this
|
||||
/// collections and documents for this
|
||||
/// <see cref="WebDavServer" />.</param>
|
||||
/// <param name="listener">The
|
||||
/// <param name="listener">The
|
||||
/// <see cref="IHttpListener" /> object that will handle the web server portion of
|
||||
/// the WebDAV server; or
|
||||
/// the WebDAV server; or
|
||||
/// <c>null</c> to use a fresh one.</param>
|
||||
/// <param name="methodHandlers">A collection of HTTP method handlers to use by this
|
||||
/// <param name="methodHandlers">A collection of HTTP method handlers to use by this
|
||||
/// <see cref="WebDavServer" />;
|
||||
/// or
|
||||
/// or
|
||||
/// <c>null</c> to use the built-in method handlers.</param>
|
||||
/// <exception cref="System.ArgumentNullException"><para>
|
||||
/// <paramref name="listener" /> is <c>null</c>.</para>
|
||||
|
@ -91,8 +91,8 @@ namespace WebDAVSharp.Server
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the
|
||||
/// <see cref="IHttpListener" /> that this
|
||||
/// Gets the
|
||||
/// <see cref="IHttpListener" /> that this
|
||||
/// <see cref="WebDavServer" /> uses for
|
||||
/// the web server portion.
|
||||
/// </summary>
|
||||
|
@ -138,7 +138,7 @@ namespace WebDAVSharp.Server
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts this
|
||||
/// Starts this
|
||||
/// <see cref="WebDavServer" /> and returns once it has
|
||||
/// been started successfully.
|
||||
/// </summary>
|
||||
|
@ -169,7 +169,7 @@ namespace WebDAVSharp.Server
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts this
|
||||
/// Starts this
|
||||
/// <see cref="WebDavServer" /> and returns once it has
|
||||
/// been stopped successfully.
|
||||
/// </summary>
|
||||
|
@ -241,6 +241,8 @@ namespace WebDAVSharp.Server
|
|||
|
||||
IHttpListenerContext context = (IHttpListenerContext)state;
|
||||
|
||||
_log.Debug(" WebDAVSharp => " + context?.AdaptedInstance?.User?.Identity?.ToString());
|
||||
|
||||
// For authentication
|
||||
Thread.SetData(Thread.GetNamedDataSlot(HttpUser), context.AdaptedInstance.User.Identity);
|
||||
|
||||
|
|
|
@ -36,17 +36,17 @@ namespace WebDAVSharp.Server {
|
|||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="WebDavServer" /> class.
|
||||
/// </summary>
|
||||
/// <param name="store">The
|
||||
/// <param name="store">The
|
||||
/// <see cref="IWebDavStore" /> store object that will provide
|
||||
/// collections and documents for this
|
||||
/// collections and documents for this
|
||||
/// <see cref="WebDavServer" />.</param>
|
||||
/// <param name="listener">The
|
||||
/// <param name="listener">The
|
||||
/// <see cref="IHttpListener" /> object that will handle the web server portion of
|
||||
/// the WebDAV server; or
|
||||
/// the WebDAV server; or
|
||||
/// <c>null</c> to use a fresh one.</param>
|
||||
/// <param name="methodHandlers">A collection of HTTP method handlers to use by this
|
||||
/// <param name="methodHandlers">A collection of HTTP method handlers to use by this
|
||||
/// <see cref="WebDavServer" />;
|
||||
/// or
|
||||
/// or
|
||||
/// <c>null</c> to use the built-in method handlers.</param>
|
||||
/// <exception cref="System.ArgumentNullException"><para>
|
||||
/// <paramref name="listener" /> is <c>null</c>.</para>
|
||||
|
@ -88,8 +88,8 @@ namespace WebDAVSharp.Server {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the
|
||||
/// <see cref="IHttpListener" /> that this
|
||||
/// Gets the
|
||||
/// <see cref="IHttpListener" /> that this
|
||||
/// <see cref="WebDavServer" /> uses for
|
||||
/// the web server portion.
|
||||
/// </summary>
|
||||
|
@ -131,7 +131,7 @@ namespace WebDAVSharp.Server {
|
|||
}
|
||||
|
||||
///// <summary>
|
||||
///// Starts this
|
||||
///// Starts this
|
||||
///// <see cref="WebDavServer" /> and returns once it has
|
||||
///// been started successfully.
|
||||
///// </summary>
|
||||
|
@ -162,7 +162,7 @@ namespace WebDAVSharp.Server {
|
|||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Starts this
|
||||
/// Starts this
|
||||
/// <see cref="WebDavServer" /> and returns once it has
|
||||
/// been stopped successfully.
|
||||
/// </summary>
|
||||
|
@ -232,10 +232,10 @@ namespace WebDAVSharp.Server {
|
|||
|
||||
//TODO: (Charly): enable authentication
|
||||
// For authentication
|
||||
Thread.SetData(Thread.GetNamedDataSlot(HttpUser), context.User.Identity);
|
||||
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}", "Info"); //
|
||||
_log.Debug($"WebDAV - {context.Request.HttpMethod} - {fileName} - {context.User?.Identity?.AuthenticationType}: {context.User?.Identity?.Name}");
|
||||
try {
|
||||
try {
|
||||
string method = context.Request.HttpMethod;
|
||||
|
@ -289,7 +289,7 @@ namespace WebDAVSharp.Server {
|
|||
string headers = "";
|
||||
try {
|
||||
foreach (var key in context.Response.Headers.AllKeys) {
|
||||
headers += $"\t{key}: {context.Response.Headers[key]}\n";
|
||||
headers += $"\t{key}: {context.Response.Headers[key]}\n";
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
|
Loading…
Reference in New Issue