Http功能增强

This commit is contained in:
tursom 2019-11-21 13:47:23 +08:00
parent cb61ac0ca7
commit 367b3067c0
2 changed files with 183 additions and 161 deletions

View File

@ -174,4 +174,26 @@ interface HttpContent {
)
fun setContextType(type: Any) = setResponseHeader("Content-Type", type)
fun jump(url: String) = temporaryMoved(url)
fun moved(url: String) = permanentlyMoved(url)
fun permanentlyMoved(url: String) {
setResponseHeader("Location", url)
finish(301)
}
fun temporaryMoved(url: String) {
noStore()
setResponseHeader("Location", url)
finish(302)
}
fun noCache() {
setResponseHeader("Cache-Control", "no-cache")
}
fun noStore() {
setResponseHeader("Cache-Control", "no-store")
}
}