public interface HttpResponse
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addCookie(Cookie cookie)
添加Cookie信息
|
void |
addHeader(String name,
String value)
Adds a response header with the given name and value.
|
void |
close() |
int |
getContentLength() |
String |
getContentType() |
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.
|
int |
getHttpStatus()
获取Http响应状态
|
BufferOutputStream |
getOutputStream()
响应消息输出流
|
String |
getReasonPhrase()
获取Http响应描述
|
void |
setContentLength(int 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 httpStatus,
String reasonPhrase)
设置Http响应状态,若不设置默认
HttpStatus.OK |
void |
write(byte[] data) |
BufferOutputStream getOutputStream()
int getHttpStatus()
void setHttpStatus(HttpStatus httpStatus)
HttpStatus.OKhttpStatus - void setHttpStatus(int httpStatus,
String reasonPhrase)
HttpStatus.OKhttpStatus - String getReasonPhrase()
void setHeader(String name, String value)
containsHeader method can be used to test for the presence
of a header before setting its value.name - 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)addHeader(java.lang.String, java.lang.String)void addHeader(String name, String value)
name - 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)setHeader(java.lang.String, java.lang.String)Collection<String> getHeaders(String name)
name - Header name to look upCollection<String> getHeaderNames()
void setContentLength(int contentLength)
int getContentLength()
void setContentType(String contentType)
String getContentType()
void write(byte[] data)
throws IOException
IOExceptionvoid close()
void addCookie(Cookie cookie)
cookie - Copyright © 2024. All rights reserved.