public class Response extends Object
| Constructor and Description |
|---|
Response(com.sun.net.httpserver.HttpExchange exchange) |
| Modifier and Type | Method and Description |
|---|---|
String |
getContentType() |
List<String> |
getHeader(String key) |
Logger |
getLogger()
Returns the logger which is concered for this Response object.
|
int |
getStatus() |
boolean |
isClosed() |
void |
redirect(String location)
Sets the response Location HTTP header to the specified path parameter.
|
void |
send()
Send an empty response (Content-Length = 0)
|
boolean |
send(Path file)
Send an entire file as response
The mime type will be automatically detected.
|
void |
send(String s)
Send an string as response.
|
boolean |
sendAttachment(Path file)
Sets the 'Content-Disposition' header to 'attachment' and his
Content-Disposition "filename=" parameter to the file name.
|
boolean |
sendBytes(byte[] bytes)
Send a byte array as response.
|
void |
sendStatus(Status status)
Set the response-status and send the response.
|
void |
setContentType(MediaType contentType)
Set the contentType for this response.
|
void |
setContentType(String contentType)
Set the contentType for this response.
|
Response |
setCookie(Cookie cookie)
Set an cookie.
|
Response |
setHeader(String key,
String value)
Add an specific value to the reponse header.
|
Response |
setStatus(Status status)
Set the response-status.
|
boolean |
streamFrom(long contentLength,
InputStream is,
MediaType mediaType)
Streams a inputstream to the client.
|
public Response setHeader(String key, String value)
key - The header name.value - The header value.public List<String> getHeader(String key)
key - The header key.public void redirect(String location)
location - The location.public Response setCookie(Cookie cookie)
cookie - The cookie.public int getStatus()
public Response setStatus(Status status)
status - The response status.public void sendStatus(Status status)
status - The response status.public String getContentType()
public void setContentType(MediaType contentType)
contentType - - The contentTypepublic void setContentType(String contentType)
contentType - - The contentTypepublic void send()
public void send(String s)
s - The string.public boolean sendAttachment(Path file)
file - The file which will be send as attachment.public boolean send(Path file)
file - The file.public boolean sendBytes(byte[] bytes)
bytes - Byte arraapublic boolean streamFrom(long contentLength,
InputStream is,
MediaType mediaType)
contentLength - Total sizeis - InputstreammediaType - Stream typepublic boolean isClosed()
public Logger getLogger()
Copyright © 2019. All rights reserved.