Skip to content

Commit

Permalink
Fix redirects only working for GET requests. (#1517)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmelchior authored Sep 14, 2023
1 parent bf06ff8 commit 619826b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* None.

### Fixed
* None.
* [Sync] If calling a function on App Services that resulted in a redirect, it would only redirect for GET requests. (Issue [#1517](https://github.com/realm/realm-kotlin/pull/1517))

### Compatibility
* File format: Generates Realms with file format v23.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package io.realm.kotlin.mongodb.internal

import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.plugins.HttpRedirect
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.logging.LogLevel
import io.ktor.client.plugins.logging.Logger
Expand Down Expand Up @@ -34,7 +35,11 @@ internal fun createClient(timeoutMs: Long, customLogger: Logger?): HttpClient {
}
}

followRedirects = true
// We should allow redirects for all types, not just GET and HEAD
// See https://github.com/ktorio/ktor/issues/1793
install(HttpRedirect) {
checkHttpMethod = false
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package io.realm.kotlin.test.mongodb.util

import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.plugins.HttpRedirect
import io.ktor.client.plugins.HttpTimeout
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.client.plugins.logging.Logger
Expand Down Expand Up @@ -65,7 +66,11 @@ fun defaultClient(name: String, debug: Boolean, block: HttpClientConfig<*>.() ->
}
}

followRedirects = true
// We should allow redirects for all types, not just GET and HEAD
// See https://github.com/ktorio/ktor/issues/1793
install(HttpRedirect) {
checkHttpMethod = false
}

// TODO connectionPool?
this.apply(block)
Expand Down

0 comments on commit 619826b

Please sign in to comment.