diff --git a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt index 75774fbed..42d5e630b 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/client/EhEngine.kt @@ -254,13 +254,18 @@ object EhEngine { append("edit_comment", id.toString()) } } - }.fetchUsingAsText { - val document = Jsoup.parse(this) - val elements = document.select("#chd + p") - if (elements.size > 0) { - throw EhException(elements[0].text()) + }.execute { response -> + // Ktor does not handle POST redirect, we need to do it manually + // https://youtrack.jetbrains.com/issue/KTOR-478 + val location = response.headers["Location"] ?: url + ehRequest(location, url).fetchUsingAsText { + val document = Jsoup.parse(this) + val elements = document.select("#chd + p") + if (elements.size > 0) { + throw EhException(elements[0].text()) + } + GalleryDetailParser.parseComments(document) } - GalleryDetailParser.parseComments(document) } suspend fun modifyFavorites(gid: Long, token: String?, dstCat: Int = -1, note: String = "") {