public interface HttpBody
Modifier and Type | Method and Description |
---|---|
default long |
contentLength()
获取写出字节长度,未知为-1
|
String |
contentType()
获取Content-Type
根据实现不同,Content-Type可能包含编码信息,也可以不包含 |
default String |
contentType(Charset charset)
获取指定编码的Content-Type,类似于:application/json;charset=UTF-8
如果 contentType() 已经包含编码信息,则编码信息一致直接返回,否则替换为指定编码。 |
default byte[] |
getBytes()
获取请求(响应)体字节码
|
default InputStream |
getStream()
获取body资源流
|
void |
write(OutputStream out)
写出数据,不关闭流
|
default void |
writeClose(OutputStream out)
写出并关闭
OutputStream |
void write(OutputStream out)
out
- out流String contentType()
default long contentLength()
default String contentType(Charset charset)
contentType()
已经包含编码信息,则编码信息一致直接返回,否则替换为指定编码。charset
- 编码contentType()
default void writeClose(OutputStream out)
OutputStream
out
- OutputStream
default InputStream getStream()
InputStream
default byte[] getBytes()
Copyright © 2025. All rights reserved.