Conversation
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
|
Very cool! Is it possible to keep API the same ( When it's ready, please request review from @sunkup. |
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
There was a problem hiding this comment.
Pull Request Overview
Updates the project to use OkHttp 5.1.0 and migrates MockWebServer tests to the new immutable MockResponse.Builder API, replaces shutdown() with close(), and adds logic in DavResource to detect empty response bodies.
- Migrate tests to
mockwebserver3.MockResponse.Builderand update assertions to use new APIs. - Add
isEmptyResponseBodyhelper inDavResourceto handle non-nullResponse.body. - Validate and adjust multi-status responses in
DavResource.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/test/kotlin/at/bitfire/dav4jvm/... | Tests updated to use MockResponse.Builder and close(). |
| src/main/kotlin/at/bitfire/dav4jvm/DavResource.kt | Added isEmptyResponseBody and adjusted assertMultiStatus. |
| gradle/libs.versions.toml | Upgraded okhttp and mockwebserver artifact versions. |
Comments suppressed due to low confidence (1)
src/main/kotlin/at/bitfire/dav4jvm/DavResource.kt:734
- [nitpick] Method name
isEmptyResponseBodysuggests it returns true when the body is empty, but its doc and logic return true when a body is present. Consider renaming this method tohasResponseBodyor inverting its return values to match its name and documentation.
private fun isEmptyResponseBody(response: Response): Boolean {
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
There was a problem hiding this comment.
Very nice! Some comments:
- In
assertMultiStatus, we have
val firstBytes = ByteArray(XML_SIGNATURE.size)
body.source().peek().readFully(firstBytes)There's now response.peekBody(size) and we can directly use its return value to check the XML signature:
response.peekBody(XML_SIGNATURE.size).use {
// …
}- We have some
httpResponse.body?.in the code. Body is now non-nullable, so we can remove the?.
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
Signed-off-by: Arnau Mora <arnyminerz@proton.me>
There were some things changed on
MockWebServer. Mainly thatMockResponsenow is immutable, soMockResponse.Builderexists; some function names have been changed.Also
Response.bodynow is never null, so in order to check whether a body has been set or not, I've checked whether the response length is0, and whether it has a content type. If none of this conditions apply, body is not set. This is done like this instead of simply checking for content length because when content type is not set we automatically assume it's XML.