public class RawResponse extends Object implements AutoCloseable
| 限定符和类型 | 方法和说明 |
|---|---|
RawResponse |
charset(Charset charset)
Set response read charset.
|
void |
close() |
void |
discardBody()
Consume and discard this response body
|
Collection<Cookie> |
getCookies()
Get all cookies
|
Cookie |
getFirstCookie(String name)
Get first cookie match the name, return null if not exists
|
String |
getFirstHeader(String name)
Get header value with name.
|
List<Parameter<String>> |
getHeaders()
Return immutable response header list
|
List<String> |
getHeaders(String name)
Get all headers values with name.
|
InputStream |
getInput()
The response body input stream
|
int |
getStatusCode()
The response status code
|
String |
getStatusLine()
Get the status line
|
byte[] |
readToBytes()
Read response body to byte array. return empty byte array if response has no body
|
<T> T |
readToJson(Class<T> cls)
Deserialize response content as json
|
<T> T |
readToJson(Type type)
Deserialize response content as json
|
<T> T |
readToJson(TypeInfer<T> typeInfer)
Deserialize response content as json
|
String |
readToText()
Read response body to string. return empty string if response has no body
|
Response<byte[]> |
toBytesResponse()
Convert to response, with body as byte array
|
Response<File> |
toFileResponse(Path path)
Write response body to file, and return response contains the file.
|
<T> Response<T> |
toJsonResponse(Class<T> cls)
Convert http response body to json result
|
<T> Response<T> |
toJsonResponse(TypeInfer<T> typeInfer)
Convert http response body to json result
|
Response<String> |
toTextResponse()
Convert to response, with body as text.
|
RawResponse |
withCharset(Charset charset)
已过时。
use {
charset(Charset)} instead |
void |
writeTo(OutputStream out)
Write response body to OutputStream.
|
void |
writeTo(Writer writer)
Write response body to Writer, charset can be set using
charset(Charset), or will use charset detected from response header if not set. |
void |
writeToFile(File file)
Write response body to file
|
void |
writeToFile(Path path)
Write response body to file
|
void |
writeToFile(String path)
Write response body to file
|
public void close()
close 在接口中 AutoCloseable@Deprecated public RawResponse withCharset(Charset charset)
charset(Charset)} insteadpublic RawResponse charset(Charset charset)
public String readToText()
public Response<String> toTextResponse()
public byte[] readToBytes()
public Response<byte[]> toBytesResponse()
public <T> T readToJson(Type type)
public <T> T readToJson(TypeInfer<T> typeInfer)
public <T> T readToJson(Class<T> cls)
public <T> Response<T> toJsonResponse(TypeInfer<T> typeInfer)
public <T> Response<T> toJsonResponse(Class<T> cls)
public void writeToFile(File file)
public void writeToFile(Path path)
public void writeToFile(String path)
public Response<File> toFileResponse(Path path)
public void writeTo(OutputStream out)
public void writeTo(Writer writer)
charset(Charset), or will use charset detected from response header if not set.
Writer will not be closed.public void discardBody()
public int getStatusCode()
public String getStatusLine()
public InputStream getInput()
@Nullable public String getFirstHeader(String name)
@Nonnull public List<Parameter<String>> getHeaders()
@Nonnull public List<String> getHeaders(String name)
public Collection<Cookie> getCookies()
Copyright © 2017. All rights reserved.