DecaTec / Portable-WebDAV-Library

Moved to codeberg.org - https://codeberg.org/DecaTec/Portable-WebDAV-Library - The Portable WebDAV Library is a strongly typed, async WebDAV client library which is fully compliant to RFC 4918, RFC 4331 and "Additional WebDAV Collection Properties". It is implemented as .NETStandard 1.1 library in oder to be used on any platform supporting .NETStandard 1.1.
https://decatec.de
Microsoft Public License
46 stars 11 forks source link

Fix locktoken formatting and make the API more strongly typed #35

Closed TomGroeneboer closed 7 years ago

TomGroeneboer commented 7 years ago

We are working on the FontoXML WebDAV implementation and while using the LockToken APIs, we thought that it could be more strong-typed and more spec-compliant.

Also, we came upon an issue with the locktokens; The WebDavHelper class filters the locktoken out of the WebDavResponseMessage and returns it from the method GetLockTokenFromWebDavResponseMessage. We are saving these locktokens on our end and are using the RawLockToken property on the LockToken class for this. However, the RawLockToken keeps the formatting of the locktoken as it was sent by the server. E.g. a Lock-Token header responds like <lock-token>.

This PR enables retrieving strong-typed versions of Lock-Token formats. It includes the following formats described in the WebDAV specification:

The strong-typed classes prevent using the 'string magic' in the current LockToken.ToString(LockTokenFormat) method. I have updated the unittests to make sure only the correct formats of Lock-Tokens can be generated.

Please let me know if something needs to be changed to meet your requirements.

DecaTec commented 7 years ago

Thanks for your great work. :thumbsup: Even with unit tests, I'm excited :smiley:

TomGroeneboer commented 7 years ago

Thanks for merging the PR so quickly. Would you be so kind to release a new version of the NuGet package when you're ready? :)

DecaTec commented 7 years ago

For v0.7.1.0 I'm also busy with an issue when the lib is used on Xamarin. I'll update the doc (version history) and release beta3 on MyGet. As soon as I get positive response about the Xamarin issue (see https://github.com/DecaTec/Portable-WebDAV-Library/issues/34), I'll prepare for the official v0.7.1.0 release.

DecaTec commented 7 years ago

v0.7.1.0-beta3 available on MyGet.

DecaTec commented 7 years ago

Currently I'm writing the mocked unit test for WebDavClient. I've changed the class AbsoluteUri, so that is has public constructors now.

The only thing which I currently cannot test is Refreshing a lock. IIS uses this as a lock token: (<opaquelocktoken:0af5a3d3-2ccd-42fb-b8c7-9c59c9b90944.22bc01d2b2e0e947>). But now I can't construct such a LockToken simply by using string (No-Tag List). So I think we need to change the code a little bit.

I comitted today's work (head), just in case you want to have a look at it.

TomGroeneboer commented 7 years ago

Hi, I'm sorry for the late response. Why did you change the constructors to public and added additional ones? Only for unittest purposes? Because you should only use the TryParse methods to prevent consumers of violating the specifications.

I have discovered a little bug in the code in this PR, the AbsoluteUri.ToString() method does some kind of URI-decoding which it should not do. I will fix it and send another PR to fix it.