mirror of
https://github.com/Corewala/Buran
synced 2025-01-03 05:34:28 +00:00
Removed redundant ouri and fixed local redirects (again)
This commit is contained in:
parent
319b0b4d14
commit
0ae42a214d
3 changed files with 6 additions and 14 deletions
|
@ -70,10 +70,10 @@ class OmniTerm(private val listener: Listener) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGlobalUri(reference: String): String {
|
fun getGlobalUri(reference: String): String {
|
||||||
when {
|
return when {
|
||||||
reference.contains(":") -> return reference
|
reference.contains(":") -> reference
|
||||||
reference.startsWith("//") -> return "gemini:$reference"
|
reference.startsWith("//") -> "gemini:$reference"
|
||||||
else -> return uri.resolve(reference)
|
else -> uri.resolve(reference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
|
||||||
when {
|
when {
|
||||||
currentRequestAddress != uri.toString() -> {}
|
currentRequestAddress != uri.toString() -> {}
|
||||||
header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header))
|
header.code == GeminiResponse.INPUT -> onUpdate(GemState.ResponseInput(uri, header))
|
||||||
header.code == GeminiResponse.REDIRECT -> onUpdate(GemState.Redirect(resolve(uri, header.meta)))
|
header.code == GeminiResponse.REDIRECT -> onUpdate(GemState.Redirect(header.meta))
|
||||||
header.code == GeminiResponse.CLIENT_CERTIFICATE_REQUIRED -> onUpdate(GemState.ClientCertRequired(uri, header))
|
header.code == GeminiResponse.CLIENT_CERTIFICATE_REQUIRED -> onUpdate(GemState.ClientCertRequired(uri, header))
|
||||||
header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header))
|
header.code != GeminiResponse.SUCCESS -> onUpdate(GemState.ResponseError(header))
|
||||||
header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, requestEntity.trim().toURI(), header, onUpdate)
|
header.meta.startsWith("text/gemini") -> getGemtext(bufferedReader, requestEntity.trim().toURI(), header, onUpdate)
|
||||||
|
@ -173,8 +173,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
|
||||||
outWriter.close()
|
outWriter.close()
|
||||||
|
|
||||||
socket.close()
|
socket.close()
|
||||||
|
|
||||||
currentRequestAddress = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getGemtext(reader: BufferedReader, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){
|
private fun getGemtext(reader: BufferedReader, uri: URI, header: GeminiResponse.Header, onUpdate: (state: GemState) -> Unit){
|
||||||
|
@ -241,12 +239,6 @@ class GeminiDatasource(private val context: Context, val history: BuranHistory):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun resolve(uri: URI, address: String): String{
|
|
||||||
val ouri = OppenURI()
|
|
||||||
ouri.set(uri.scheme + uri.host)
|
|
||||||
return ouri.resolve(address)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun canGoBack(): Boolean = runtimeHistory.isEmpty() || runtimeHistory.size > 1
|
override fun canGoBack(): Boolean = runtimeHistory.isEmpty() || runtimeHistory.size > 1
|
||||||
|
|
||||||
//This just forces the factory to rebuild before the next request
|
//This just forces the factory to rebuild before the next request
|
||||||
|
|
|
@ -458,7 +458,7 @@ class GemActivity : AppCompatActivity() {
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
is GemState.Redirect -> gemRequest(state.uri)
|
is GemState.Redirect -> gemRequest(omniTerm.getGlobalUri(state.uri))
|
||||||
|
|
||||||
is GemState.ClientCertRequired -> runOnUiThread {
|
is GemState.ClientCertRequired -> runOnUiThread {
|
||||||
loadingView(false)
|
loadingView(false)
|
||||||
|
|
Loading…
Reference in a new issue