mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-30 03:48:05 +02:00
cleaner code
This commit is contained in:
@@ -50,8 +50,8 @@ class Request(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
val httpURLConnection = url.openConnection() as HttpURLConnection
|
val httpURLConnection = url.openConnection() as HttpURLConnection
|
||||||
httpURLConnection.setReadTimeout(10000)
|
httpURLConnection.readTimeout = 10000
|
||||||
httpURLConnection.setConnectTimeout(10000)
|
httpURLConnection.connectTimeout = 10000
|
||||||
httpURLConnection.setRequestProperty("User-Agent", "OpenTimestamps Java")
|
httpURLConnection.setRequestProperty("User-Agent", "OpenTimestamps Java")
|
||||||
httpURLConnection.setRequestProperty("Accept", "application/json")
|
httpURLConnection.setRequestProperty("Accept", "application/json")
|
||||||
httpURLConnection.setRequestProperty("Accept-Encoding", "gzip")
|
httpURLConnection.setRequestProperty("Accept-Encoding", "gzip")
|
||||||
@@ -62,7 +62,7 @@ class Request(
|
|||||||
|
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
httpURLConnection.setDoOutput(true)
|
httpURLConnection.setDoOutput(true)
|
||||||
httpURLConnection.setRequestMethod("POST")
|
httpURLConnection.requestMethod = "POST"
|
||||||
httpURLConnection.setRequestProperty(
|
httpURLConnection.setRequestProperty(
|
||||||
"Content-Length",
|
"Content-Length",
|
||||||
"" + this.data!!.size.toString(),
|
"" + this.data!!.size.toString(),
|
||||||
@@ -72,7 +72,7 @@ class Request(
|
|||||||
wr.flush()
|
wr.flush()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
httpURLConnection.setRequestMethod("GET")
|
httpURLConnection.requestMethod = "GET"
|
||||||
}
|
}
|
||||||
|
|
||||||
httpURLConnection.connect()
|
httpURLConnection.connect()
|
||||||
@@ -84,7 +84,7 @@ class Request(
|
|||||||
response.status = responseCode
|
response.status = responseCode
|
||||||
response.fromUrl = url.toString()
|
response.fromUrl = url.toString()
|
||||||
var `is` = httpURLConnection.getInputStream()
|
var `is` = httpURLConnection.getInputStream()
|
||||||
if ("gzip" == httpURLConnection.getContentEncoding()) {
|
if ("gzip" == httpURLConnection.contentEncoding) {
|
||||||
`is` = GZIPInputStream(`is`)
|
`is` = GZIPInputStream(`is`)
|
||||||
}
|
}
|
||||||
response.setStream(`is`)
|
response.setStream(`is`)
|
||||||
|
@@ -54,7 +54,7 @@ class Response : Closeable {
|
|||||||
|
|
||||||
@get:Throws(IOException::class)
|
@get:Throws(IOException::class)
|
||||||
val string: String
|
val string: String
|
||||||
get() = kotlin.text.String(this.bytes, StandardCharsets.UTF_8)
|
get() = String(this.bytes, StandardCharsets.UTF_8)
|
||||||
|
|
||||||
@get:Throws(IOException::class)
|
@get:Throws(IOException::class)
|
||||||
val bytes: ByteArray
|
val bytes: ByteArray
|
||||||
|
Reference in New Issue
Block a user