andyg
11/10/2023, 1:55 PMLocation
header is absolute <https://www.mysite.com/foo/bar/page.htm>
or relative /foo/bar/page.htm
or just page.htm
(not sure if the last one is legal, although plenty of servers produce non-compliant responses). I built a pretty simple implementation but I may have missed edge cases. Thanks!dave
11/10/2023, 1:58 PMResponse(Status.SEE_OTHER).with(Header.LOCATION of Uri.of('<http://this_can_have_a_server/or_be_just_a_path'))>
andyg
11/10/2023, 2:11 PMif (locationHeader.startsWith("http")) locationHeader else java.net.URI(originalRequest.uri.scheme, originalRequest.uri.host, locationHeader, "").toString()
dave
11/10/2023, 2:20 PMval completeHost = Filter { next ->
{ req ->
next(req).run {
if (status.redirection) {
val redirect = Header.LOCATION(this)
when {
redirect.host != req.uri.host -> removeHeader("host")
.with(Header.LOCATION of redirect.scheme(req.uri.scheme).authority(req.uri.authority))
else -> this
}
} else this
}
}
}
andyg
11/10/2023, 2:44 PMcommonParse
function which is 150+ lines. that is overkill for my use case, I think some mix of mine and yours will be sufficient 👍dave
11/10/2023, 3:35 PMandyg
11/11/2023, 12:51 AM