Skip to content

Conversation

@ArnyminerZ
Copy link
Member

  • Fixed usages of HttpHeaders: created our own HTTP headers constants file.
  • Annotated all functions from common code that use ktor with @UsesKtor:
    • Basically we are only using ContentType, but it's a bit too complex to implement it on our own, so at least annotate it.

@ArnyminerZ ArnyminerZ linked an issue Nov 11, 2025 that may be closed by this pull request
@ArnyminerZ ArnyminerZ self-assigned this Nov 11, 2025
@ArnyminerZ ArnyminerZ added the refactoring Internal improvement of existing functions label Nov 11, 2025
@ArnyminerZ ArnyminerZ marked this pull request as ready for review November 11, 2025 12:13
@ArnyminerZ ArnyminerZ requested a review from rfc2822 November 11, 2025 12:13
Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of having a manually maintained annotation for Ktor dependencies. It looks error-prone and if we just forget a single thing (or forget to not use such annotated methods in DAVx5 code), everything breaks.

So considering that we want to transition to Ktor anyway, I think we can keep the ktor code for simplicity and just not exclude the ktor library in DAVx5.

And then hopefully make progress to move everything to ktor …

@ArnyminerZ
Copy link
Member Author

I'm not a fan of having a manually maintained annotation for Ktor dependencies. It looks error-prone and if we just forget a single thing (or forget to not use such annotated methods in DAVx5 code), everything breaks.

Maybe we just specify it in the comments? To be sure. Because with other functions it's clear (for example, they use a ktor reference in the arguments), but for others (such as they use ContentType), it's not clear from the caller side.

@rfc2822
Copy link
Member

rfc2822 commented Nov 12, 2025

Maybe we just specify it in the comments? To be sure. Because with other functions it's clear (for example, they use a ktor reference in the arguments), but for others (such as they use ContentType), it's not clear from the caller side.

However we'd then have to remove it again when we drop okhttp …

I think we should keep ktor usage in common code as little as possible, but it's acceptable. We just need to know that Ktor must not be excluded in gradle.

So maybe mention that in the README? That dav4jvm is currently in a rewrite phase to Ktor and that ktor must not be excluded. We can then update it when we remove okhttp from the dependencies.

Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
@ArnyminerZ
Copy link
Member Author

I've updated everything, and added a note to the README. Maybe the title of the PR should be updated now

Copy link
Member

@rfc2822 rfc2822 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a comment to the Ktor issue: #72 (comment)

Comment on lines +15 to +18
const val Accept: String = "Accept"

/** [RFC4229 Section-2.1.5](https://datatracker.ietf.org/doc/html/rfc4229#section-2.1.5) */
const val AcceptEncoding: String = "Accept-Encoding"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. There are some references (especially in DavResource), we can replace them right now so that the new constants are actually used.

We can replace header names in other places whenever we change code in those places.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can replace them right now so that the new constants are actually used.

So we want to ignore completely that ktor's HttpHeaders exists, and use our own, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok now I'm confused, I thought ktor HttpHeaders is rather an internal class.

But it's part of the API, so we can of course use HttpHeaders everywhere, especially as we have given up the strict separation of okhttp and ktor.

So we won't need this class (HttpHeaderNames) at all because ktor HttpHeaders also defines ETag and ScheduleTag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Internal improvement of existing functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

okhttp packages can't be used without ktor

2 participants