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