public class OkHttpResponse extends Object implements HttpResponse
| Constructor and Description |
|---|
OkHttpResponse(OkHttpUtils utils,
int statusCode,
okhttp3.Response response) |
| Modifier and Type | Method and Description |
|---|---|
InputStream |
body()
获取响应主体
|
<T> T |
bodyAsBean(Type type)
获取响应主体并转为对象
|
byte[] |
bodyAsBytes()
获取响应主体并转为字节数组
|
String |
bodyAsString()
获取响应主体并转为字符串
|
void |
close() |
int |
code()
获取状态代码
|
Charset |
contentCharset()
获取内容字符集
|
Long |
contentLength()
获取内容长度
|
String |
contentType()
获取内容类型
|
String |
cookie(String name)
获取饼值
|
Collection<String> |
cookieNames()
获取饼名
|
List<String> |
cookies()
获取小饼数组
|
List<String> |
cookies(String name)
获取饼值数组
|
HttpResponseException |
createError()
创建响应异常
|
String |
header(String name)
获取头值
|
Collection<String> |
headerNames()
获取头名
|
List<String> |
headers(String name)
获取头值数组
|
String |
message()
获取状态消息
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcontentEncodingpublic OkHttpResponse(OkHttpUtils utils, int statusCode, okhttp3.Response response)
public Collection<String> headerNames()
HttpResponseheaderNames in interface HttpResponsepublic String header(String name)
HttpResponseheader in interface HttpResponsepublic List<String> headers(String name)
HttpResponseheaders in interface HttpResponsepublic Collection<String> cookieNames()
HttpResponsecookieNames in interface HttpResponsepublic String cookie(String name)
HttpResponsecookie in interface HttpResponsepublic List<String> cookies(String name)
HttpResponsecookies in interface HttpResponsepublic Long contentLength()
HttpResponsecontentLength in interface HttpResponsepublic String contentType()
HttpResponsecontentType in interface HttpResponsepublic Charset contentCharset()
HttpResponsecontentCharset in interface HttpResponsepublic List<String> cookies()
HttpResponsecookies in interface HttpResponsepublic int code()
HttpResponsecode in interface HttpResponsepublic String message()
HttpResponsemessage in interface HttpResponsepublic InputStream body()
HttpResponsebody in interface HttpResponsepublic byte[] bodyAsBytes()
throws IOException
HttpResponsebodyAsBytes in interface HttpResponseIOExceptionpublic String bodyAsString() throws IOException
HttpResponsebodyAsString in interface HttpResponseIOExceptionpublic <T> T bodyAsBean(Type type) throws IOException
HttpResponsebodyAsBean in interface HttpResponseIOExceptionpublic HttpResponseException createError()
HttpResponsecreateError in interface HttpResponsepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2025. All rights reserved.