public static interface Renderer.Context
Modifier and Type | Method and Description |
---|---|
boolean |
accepts(MediaType type)
True if the given type matches the
Accept header. |
default boolean |
accepts(String type)
True if the given type matches the
Accept header. |
Charset |
charset() |
Renderer.Context |
length(long length)
Set the
Content-Length header IF and ONLY IF, no Content-Length was
set yet. |
Locale |
locale()
Request locale or default locale.
|
Map<String,Object> |
locals() |
void |
send(byte[] bytes)
Write bytes into the HTTP response body.
|
void |
send(ByteBuffer buffer)
Write byte buffer into the HTTP response body.
|
void |
send(CharBuffer buffer)
Write text into the HTTP response body.
|
void |
send(FileChannel file)
Write file into the HTTP response body, using OS zero-copy transfer (if possible).
|
void |
send(InputStream stream)
Write bytes into the HTTP response body.
|
void |
send(Reader reader)
Write text into the HTTP response body.
|
void |
send(String text)
Write text into the HTTP response body.
|
Renderer.Context |
type(MediaType type)
Set the
Content-Type header IF and ONLY IF, no Content-Type was set
yet. |
default Renderer.Context |
type(String type)
Set the
Content-Type header IF and ONLY IF, no Content-Type was set
yet. |
Locale locale()
default boolean accepts(String type)
Accept
header.type
- The type to check for.Accept
header.boolean accepts(MediaType type)
Accept
header.type
- The type to check for.Accept
header.default Renderer.Context type(String type)
Content-Type
header IF and ONLY IF, no Content-Type
was set
yet.type
- A suggested type to use if one is missing.Renderer.Context type(MediaType type)
Content-Type
header IF and ONLY IF, no Content-Type
was set
yet.type
- A suggested type to use if one is missing.Renderer.Context length(long length)
Content-Length
header IF and ONLY IF, no Content-Length
was
set yet.length
- A suggested length to use if one is missing.Charset charset()
void send(byte[] bytes) throws Exception
Content-Length
if none was set
It will set a Content-Type
to MediaType.octetstream
if none was set.bytes
- A bytes to write.Exception
- When the operation fails.void send(ByteBuffer buffer) throws Exception
Content-Length
if none was set.
It will set a Content-Type
to MediaType.octetstream
if none was set.buffer
- A buffer to write.Exception
- When the operation fails.void send(String text) throws Exception
Content-Length
if none was set.
It will set a Content-Type
to MediaType.html
if none was set.text
- A text to write.Exception
- When the operation fails.void send(InputStream stream) throws Exception
Content-Length
if the response size is less than the
server.ResponseBufferSize
(default is: 16k). If the response is larger than the
buffer size, it will set a Transfer-Encoding: chunked
header.
It will set a Content-Type
to MediaType.octetstream
if none was set.
This method will check if the given input stream has a FileChannel
and redirect to
filestream
- Bytes to write.Exception
- When the operation fails.void send(CharBuffer buffer) throws Exception
Content-Length
if none was set.
It will set a Content-Type
to MediaType.html
if none was set.buffer
- A text to write.Exception
- When the operation fails.void send(Reader reader) throws Exception
Content-Length
if the response size is less than the
server.ResponseBufferSize
(default is: 16k). If the response is larger than the
buffer size, it will set a Transfer-Encoding: chunked
header.
It will set a Content-Type
to MediaType.html
if none was set.reader
- Text to write.Exception
- When the operation fails.void send(FileChannel file) throws Exception
Content-Length
if none was set.
It will set a Content-Type
to MediaType.html
if none was set.file
- A text to write.Exception
- When the operation fails.Copyright © 2017. All rights reserved.