pull/977/head
parent
272163ea70
commit
f91bc8722a
@ -1,13 +0,0 @@ |
||||
package io.legado.app.help.http.parser |
||||
|
||||
import okhttp3.Response |
||||
import rxhttp.wrapper.annotation.Parser |
||||
|
||||
@Parser(name = "ByteArray") |
||||
class ByteParser : rxhttp.wrapper.parse.Parser<ByteArray> { |
||||
|
||||
override fun onParse(response: Response): ByteArray { |
||||
return response.body!!.bytes() |
||||
} |
||||
|
||||
} |
@ -1,14 +0,0 @@ |
||||
package io.legado.app.help.http.parser |
||||
|
||||
import okhttp3.Response |
||||
import rxhttp.wrapper.annotation.Parser |
||||
import java.io.InputStream |
||||
|
||||
@Parser(name = "InputStream") |
||||
class InputStreamParser : rxhttp.wrapper.parse.Parser<InputStream> { |
||||
|
||||
override fun onParse(response: Response): InputStream { |
||||
return response.body!!.byteStream() |
||||
} |
||||
|
||||
} |
@ -1,19 +0,0 @@ |
||||
package io.legado.app.help.http.parser |
||||
|
||||
import io.legado.app.help.http.StrResponse |
||||
import io.legado.app.help.http.text |
||||
import okhttp3.Response |
||||
import rxhttp.wrapper.annotation.Parser |
||||
import rxhttp.wrapper.exception.HttpStatusCodeException |
||||
|
||||
@Parser(name = "StrResponse") |
||||
class StrResponseParser(private val encode: String? = null) : |
||||
rxhttp.wrapper.parse.Parser<StrResponse> { |
||||
|
||||
override fun onParse(response: Response): StrResponse { |
||||
val body = response.body?.text(encode) |
||||
?: throw HttpStatusCodeException(response, "内容为空") |
||||
return StrResponse(response, body) |
||||
} |
||||
|
||||
} |
@ -1,17 +0,0 @@ |
||||
package io.legado.app.help.http.parser |
||||
|
||||
import io.legado.app.help.http.text |
||||
import okhttp3.Response |
||||
import rxhttp.wrapper.annotation.Parser |
||||
import rxhttp.wrapper.exception.HttpStatusCodeException |
||||
|
||||
@Parser(name = "Text") |
||||
class TextParser(private val encode: String? = null) : rxhttp.wrapper.parse.Parser<String> { |
||||
|
||||
override fun onParse(response: Response): String { |
||||
|
||||
val responseBody = response.body ?: throw HttpStatusCodeException(response, "内容为空") |
||||
return responseBody.text(encode) |
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue