Git Product home page Git Product logo

nwebdav's People

Contributors

dependabot[bot] avatar jtone123 avatar michaelpeter avatar olederle avatar ramondeklein avatar yar229 avatar zivillian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nwebdav's Issues

Sending HTTP headers

When doing a PoC for MSOffice/LibreOffice editing feature while putting the documents on a WebDAV address pointed by a href links I noticed that the HTTP headers are not sent in case of GET requests.

NWebDav is hosted on ASP.NET (not Core).

To temporarily overcome the issue I had to add a flush method that flushes the content to the response before starting to write the actual content. The flush is called before the "if (!head) await CopyToAsync" statement in GetAndHeadHandler.cs.
I don't know if something similar is required for ASP.NET Core, HttpListener and for other HTTP verbs.

WebDrive does not show folder listing

WebDrive allow to map webdav folders as drive in windows (more usable than standart win webdav client).

Tested with NWebDav.Sample.HttpListener.

Experiments with changing properties of WebDrive connection does not take effect.

Start of root element expected instead of TEXT 'null'

DAVExporer fails to connect to IIS NWebDav server and reports an XML parsing error. This apparently occurs because the XML declaration doesn't have a line separator after it. I fixed this using the following hack in ResponseHelpers.cs SendResponseAsync().

Replace


            // Obtain the result as an XML document
            using (var ms = new MemoryStream())
            {
                using (var xmlWriter = XmlWriter.Create(ms, new XmlWriterSettings
                {
                    OmitXmlDeclaration = false,

with


            // Obtain the result as an XML document
            using (var ms = new MemoryStream())
            {
                var decl = Encoding.UTF8.GetBytes("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
                ms.Write(decl, 0, decl.Length);
                using (var xmlWriter = XmlWriter.Create(ms, new XmlWriterSettings
                {
                    OmitXmlDeclaration = true,

Content-Type header not set on Asp .Net.

The ContentType property must be set instead of the header on ASP .Net 4.7.2, like this or similar:

            public void SetHeaderValue(string header, string value)
            {
                if (header.Equals("content-type", System.StringComparison.OrdinalIgnoreCase))
                {
                    _httpResponse.ContentType = value;
                }
                else
                {
                    _httpResponse.Headers.Set(header, value);
                }
            }

Hangups of WebDav on NetDrive service client if accessed to files, cannot read them.

First it hanged webdav service, then i had to terminate process and connection (i use NetDrive), on second try it sends errors:
image

[11]: PROPFIND:http://127.0.0.1:801/temp:127.0.0.1:801 - Start processing
[11]: PROPFIND:http://127.0.0.1:801/temp:127.0.0.1:801 - Finished processing (70
1ms, HTTP result: 207)
[8]: GET:http://127.0.0.1:801/Cloud/unins000.exe:127.0.0.1:801 - Finished proces
sing (3511ms, HTTP result: 200)
[4]: Exception
System.ObjectDisposedException: Access to removed object is not possible.
Имя объекта: "System.Net.HttpListenerRequest".
   в System.Net.HttpListenerRequest.CheckDisposed()
   в System.Net.HttpListenerRequest.GetKnownHeader(HttpRequestHeader header)
   в NWebDav.Server.HttpListener.HttpRequest.get_RemoteEndPoint()
   в NWebDav.Server.WebDavDispatcher.<>c__DisplayClass6_0.<DispatchRequestAsync>
b__5()
   в YaR.WebDavMailRu.Log4NetAdapter.Log4NetLoggerAdapter.Log(LogLevel logLevel,
 Func`1 messageFunc, Exception exception)
   в NWebDav.Server.WebDavDispatcher.<DispatchRequestAsync>d__6.MoveNext()
--- End of tracing stack from previous position, where exception triggered.
 ---
   в System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   в NWebDav.Server.WebDavDispatcher.<DispatchRequestAsync>d__6.MoveNext()
--- End of tracing stack from previous position, where exception triggered.
 ---
   в System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   в System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNoti
fication(Task task)
   в YaR.WebDavMailRu.Program.<>c__DisplayClass3_0.<<DispatchHttpRequestsAsync>b
__1>d.MoveNext()
[5]: PROPFIND:http://127.0.0.1:801/temp:127.0.0.1:801 - Start processing
[3]: PROPFIND:http://127.0.0.1:801/temp:127.0.0.1:801 - Finished processing (319
ms, HTTP result: 207)

Slowly tries to download, but hangs and connection lost.

HelpTest.csproj missing

When I open solution file project HelpTest can't be loaded.

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelpTest", "HelpTest\HelpTest.csproj", "{9DD916D2-B977-4E34-8296-7B3A6FA2E964}"

Use DI instead of static

For logging it would be best to use DI instead of static objects and custom implementation of ILogger. MSFT already provides ILogger, extension methods, ILoggerFactory. Using your own definition of ILogger and ILogger factory does not integrate easily with the framework. At least use the MSFT interfaces but best would be to leverage DI as well so own does not have to handle the injection in the different classes (which is probably why you have the static)

Licensing

Hi
Are you considering to post explicit licensing for this repository?

Thanks

DELETE issue

Hello!

Maybe this is a default behaviour, but when i delete a file but i haven't the permissions for this operation, i'll get an exeption on the server, but the client gets no dialog that this operation can't be done.

Is this right?

how send web api token (jwt) ?

how send web api token (jwt) on ms-word link?
when set api token on url (?token=xxxx) url long and word give exception.

Server library name

In Linux

System.IO.FileNotFoundException: Could not load file or assembly 'NWebDav.Server, Version=0.1.24.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

cause of real file name is nwebdav.server.dll
Renaming dll to NWebDav.Server.dll helps

Windows does not care about registers.
In nuget package v.0.1.21.0 dll was named correct

Handling slow/async store

Hi,

I try to implement a WebDAV-Store, that loads data from another library from the net. That library provides the result only as a file on my file-System (temp-file). So whenever a user selects a file in my store, I Need to fetch the complete file first to my local hard drive and Can then provide a file-stream on it.

Is there any way to create a Kind of async-filestream that provides new data-chunks whenever they got written to the temp-file? I'm a bit lost, currently and appreciate any help.

Thank you!

Kind regards,

TopperDEL

Deleting file from linux

I've mounted webdav server with davfs2 and cannot delete files..

yar@yarvm:~$ rm /mnt/wdmrc/favicon.ico
rm: remove write-protected regular file '/mnt/wdmrc/favicon.ico'? y
rm: cannot remove '/mnt/wdmrc/favicon.ico': Permission denied

Suppose I need to add some props to item DefaultPropertyManager?

Thanks for your answer

need documents

hi

i want work with your package but i dont khow how start and methods your package have

False upload progress percentage

I'm trying to upload a file from Windows 10 to an instance webdav server, so I'm using the network folder method to connect the remote folder.
I noticed that with file with dimension >300MB the progress percentage of the copy action is not real: it goes straigh up to 99% with a reasonable upload speed, then it seems to stop but looking at the newly created file on the server store its dimension keeps on increasing till the copy is done.

Is this a Windows issue or something related on webdav server initialization?

Server setup example

Hello!
Do you have any exmple about the webdav server initialization?
I understood that I can create a store location in this way:
var store = new NWebDav.Server.Stores.DiskStore(@"C:\")
But I wasn't able, for example, to find out how to select a http listener (ip address + port) and how to start the server.

MoveHandler MoveAsync for collections copies children individually (potentially very slow for some backing stores)

MoveHandler move function for collections has no option to take advantage of moving a whole container, but instead creates a new container, moves contents one at a time, and then deletes the original.

I am working on a personal project that has an option for a GoogleDrive backing store. I would prefer to simply change the parent of the folder, retaining the ID of the folder itself.

https://github.com/ramondeklein/nwebdav/blob/master/NWebDav.Server/Handlers/MoveHandler.cs

This function:
private async Task MoveAsync(IStoreCollection sourceCollection, string sourceName, IStoreCollection destinationCollection, string destinationName, bool overwrite, IHttpContext httpContext, Uri baseUri, UriResultCollection errors)

I am happy to make the change in a branch and add a pull request, but would ideally like to coordinate on design.

My thinking is to add a function to IStoreCollection to check if a 'fast move' of a child collection is supported, and if so just tell it to use MoveItemAsync on the parent collection to do the move (the same as if it was a file). E.g. Task SupportsMovingCollections().

If I am just missing something and there is already an easier way, please let me know.

Use custom URL class

WebDAV URLs seem to behave a little bit different from normal URLs, because they don't support fragments. This has been fixed (partially) in the UriHelper class, but the store implementation needs to call this class at appropriate times which is a bit awkward and error-prone.

A custom URL class would probaby be easier to use, but this requires breaking changes to the API.

Far and path contains #

NetBox Far plugin cannot create folder with name, for example, "#123"
If such folder already exists and you enter this one, all inner files and folders (include parent "..") looks like parent folder name.

But everything ok on, for example, webdav.yandex.ru
Also it's ok when webdav server mapped as disk drive

Other clients (Total Commander, CarotDAV) works normally

Async LockManager

Hi everybody and @ramondeklein

I would need an async lock manager since my locking would happen in a database and be asynchrouns calls.

The question is, now the ILockManager interface wouldn't allow that and I would need to replace the both Lock and Unlock Request handlers, if I would not want to do that I would need to execute all my async calls using LockAsync().Wait().

Think it would be best to make a incompatible fork? Or should I make a pull request for IAsyncLockManager?

I could add a IAsyncLock Manager Interface to the code, but then all Locking code would need a

if(LockManager is IAsyncLockManager)  
    await ((IAsyncLockManager)LockManager).LockAsync();
else 
    LockManager.Lock();

but that would make the sourcecode ugly?

(Wrong?) behavior of some clients

For example, NetBox Far plugin suppose that

  • getcontentlength for files
  • resourcetype/collection for folders

server must send always, so all files and folders looks like files with zero length

Is it really problem of NetBox?

Running HttpListener under mono does not recognise Basic Authentication

I followed your HttpListener example to put up a Webdav server.
Everything works fine running it under Windows, but I get some issues running on linux with mono.
In the DispatchHttpRequestsAsync function the request is intercepted and, with mono, the property IsAuthenticated is alway False, hance I'm not able to return the folder assigned to the user in the response.

Is there a workaround or a fix to this issue?

Upgrade .Net5 & Further Improvements

Hello Ramon, hello Community,

for various personal and professional reasons I am quite interested in pushing this project forward.
I created a pull request to upgrade to .NET5 (#60) and everybody is
welcome to review it - and make further improvements.

Very welcome is a diskussion if for example the usage if IAsyncCollection is sensible for GetItemsAsync()

Feel free to write here or contact me :)

Planning further contributions :)

For example:

  • Sample with Blazor and .NET 5, also to test one AntiForgery issue we had in the past.
  • Maybe A Sample Middleware for .NET 5.
    -- Also regarding the issue that the Windows Explorer makes PROPFIND on the root url and the Webdav should be hostet on its own port.
  • Making big files and big collections streamable, since big files would be loaded in the memory right now.
  • Public Possibility to override or extend Http-Method handlers. For Protocol Extensions or custom logic.
  • A simplefied template for implementening a custom IStore?

Also I would ask the question if the support for .NET Standard 1.6 and 2.0 should be removed? (And Just Net 4.5, NetStandard 2.1 and Net5 (and Net6) should be left.

Problem with move request for non-existing source

Problem Description

Move request of a non-existing files returns Status: 207(Multi-Status) instead of 404(Not Found).
Though I was able to confirm that Multi-Status response contains 404(Not Found) as an inner response as following :

<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n
<D:multistatus xmlns:D=\"DAV:\" xmlns:Z=\"urn:schemas-microsoft-com:\">\r\n
  <D:response>\r\n
    <D:href>https://172.21.2.220:5003/bbb</D:href>\r\n
    <D:status>HTTP/1.1 404 Not Found</D:status>\r\n
  </D:response>\r\n
</D:multistatus>

Reproduction Procedure

Make a move request where source file does not exist.

Question

Is this intended behaviors or is it a bug?

[COPY] No error generated when destination file name is too long.

Problem Description

NWebDAV return 207 (Multi-Status) status code when trying to copy a file where destination file name is too long(320 chars).
In case of IIS if you you specify a destination file name greater than 256 characters, it returns 404 error status.

I've check the source code and found following code in CopyHandler, please have a look :

// Copy collection
await CopyAsync(sourceItem, destinationCollection, destination.Name, overwrite, depth, httpContext, destination.CollectionUri, errors).ConfigureAwait(false);

// Check if there are any errors
if (errors.HasItems)
{
    // Obtain the status document
    var xDocument = new XDocument(errors.GetXmlMultiStatus());

    // Stream the document
    await response.SendResponseAsync(DavStatusCode.MultiStatus, xDocument).ConfigureAwait(false);
}
else
{
    // Set the response
    response.SetStatus(DavStatusCode.Ok);
}

Reproduction Procedure

Try to copy a file where destination file name is greater than 256 characters.

Question

Is this intended behaviors or is it a bug?

No contact information / donation information

Thank you guys, I'm using your WebDav implementation inside a WebProject with a self-written DatabaseStore. I just tweaked the authentication to match my needs and I'm very happy with your implementation. You saved me a lot of time and I wanted to thank you for that.

If you supply Donation information I would love to support you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.