public class AbstractResponse extends Object implements HttpResponse, Reset
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
closed
是否关闭Socket连接通道
|
protected org.smartboot.http.server.impl.AbstractOutputStream |
outputStream
输入流
|
| Constructor and Description |
|---|
AbstractResponse() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(Cookie cookie)
添加Cookie信息
|
void |
addHeader(String name,
String value)
Adds a response header with the given name and value.
|
void |
close() |
long |
getContentLength() |
String |
getContentType() |
List<Cookie> |
getCookies() |
String |
getHeader(String name) |
Collection<String> |
getHeaderNames()
Get the header names set for this HTTP response.
|
Collection<String> |
getHeaders(String name)
Return a Collection of all the header values associated with the
specified header name.
|
HttpStatus |
getHttpStatus()
获取Http响应状态
|
BufferOutputStream |
getOutputStream()
响应消息输出流
|
Supplier<Map<String,String>> |
getTrailerFields()
Gets the supplier of trailer headers.
|
protected void |
init(org.smartboot.socket.transport.AioSession session,
org.smartboot.http.server.impl.AbstractOutputStream outputStream) |
boolean |
isClosed()
是否要断开TCP连接
|
void |
reset() |
void |
setContentLength(long contentLength) |
void |
setContentType(String contentType) |
void |
setHeader(String name,
String value)
Sets a response header with the given name and value.
|
void |
setHttpStatus(HttpStatus httpStatus)
设置Http响应状态,若不设置默认
HttpStatus.OK |
void |
setHttpStatus(int value,
String reasonPhrase)
设置Http响应状态,若不设置默认
HttpStatus.OK |
void |
write(byte[] buffer) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsetTrailerFieldsprotected org.smartboot.http.server.impl.AbstractOutputStream outputStream
protected boolean closed
protected void init(org.smartboot.socket.transport.AioSession session,
org.smartboot.http.server.impl.AbstractOutputStream outputStream)
public final BufferOutputStream getOutputStream()
HttpResponsegetOutputStream in interface HttpResponsepublic HttpStatus getHttpStatus()
HttpResponsegetHttpStatus in interface HttpResponsepublic final void setHttpStatus(HttpStatus httpStatus)
HttpResponseHttpStatus.OKsetHttpStatus in interface HttpResponsepublic final void setHttpStatus(int value,
String reasonPhrase)
HttpResponseHttpStatus.OKsetHttpStatus in interface HttpResponsepublic final void setHeader(String name, String value)
HttpResponsecontainsHeader method can be used to test for the presence
of a header before setting its value.setHeader in interface HttpResponsename - the name of the headervalue - the header value If it contains octet string, it should be
encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)HttpResponse.addHeader(java.lang.String, java.lang.String)public final void addHeader(String name, String value)
HttpResponseaddHeader in interface HttpResponsename - the name of the headervalue - the additional header value If it contains octet string, it
should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt)HttpResponse.setHeader(java.lang.String, java.lang.String)public final String getHeader(String name)
getHeader in interface HttpResponsepublic final Collection<String> getHeaders(String name)
HttpResponsegetHeaders in interface HttpResponsename - Header name to look uppublic final Collection<String> getHeaderNames()
HttpResponsegetHeaderNames in interface HttpResponsepublic final void write(byte[] buffer)
throws IOException
write in interface HttpResponseIOExceptionpublic void close()
close in interface HttpResponsepublic void addCookie(Cookie cookie)
HttpResponseaddCookie in interface HttpResponsepublic long getContentLength()
getContentLength in interface HttpResponsepublic void setContentLength(long contentLength)
setContentLength in interface HttpResponsepublic final String getContentType()
getContentType in interface HttpResponsepublic final void setContentType(String contentType)
setContentType in interface HttpResponsepublic final boolean isClosed()
public Supplier<Map<String,String>> getTrailerFields()
HttpResponsegetTrailerFields in interface HttpResponseSupplier of trailer headersCopyright © 2025. All rights reserved.