public abstract class AbstractHttpResponder extends Object implements HttpResponder
HttpResponder to simplify child implementations.| Modifier and Type | Field and Description |
|---|---|
protected static String |
OCTET_STREAM_TYPE |
| Constructor and Description |
|---|
AbstractHttpResponder() |
| Modifier and Type | Method and Description |
|---|---|
protected io.netty.handler.codec.http.HttpHeaders |
addContentTypeIfMissing(io.netty.handler.codec.http.HttpHeaders headers,
String contentType) |
void |
sendByteArray(io.netty.handler.codec.http.HttpResponseStatus status,
byte[] bytes,
io.netty.handler.codec.http.HttpHeaders headers)
Send a response containing raw bytes.
|
void |
sendBytes(io.netty.handler.codec.http.HttpResponseStatus status,
ByteBuffer buffer,
io.netty.handler.codec.http.HttpHeaders headers)
Sends a response containing raw bytes.
|
ChunkResponder |
sendChunkStart(io.netty.handler.codec.http.HttpResponseStatus status)
Respond to the client saying the response will be in chunks.
|
void |
sendFile(File file)
Sends a file content back to client with response status 200 with content type as "application/octet-stream".
|
void |
sendJson(io.netty.handler.codec.http.HttpResponseStatus status,
String jsonString)
Sends json response back to the client.
|
void |
sendStatus(io.netty.handler.codec.http.HttpResponseStatus status)
Send only a status code back to client without any content.
|
void |
sendStatus(io.netty.handler.codec.http.HttpResponseStatus status,
io.netty.handler.codec.http.HttpHeaders headers)
Send only a status code back to client without any content.
|
void |
sendString(io.netty.handler.codec.http.HttpResponseStatus status,
String data)
Send a string response in UTF-8 encoding back to the http client.
|
void |
sendString(io.netty.handler.codec.http.HttpResponseStatus status,
String data,
io.netty.handler.codec.http.HttpHeaders headers)
Send a string response in UTF-8 encoding back to the http client.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitsendChunkStart, sendContent, sendContent, sendFileprotected static final String OCTET_STREAM_TYPE
public void sendJson(io.netty.handler.codec.http.HttpResponseStatus status,
String jsonString)
HttpResponderapplication/json.sendJson in interface HttpResponderstatus - Status of the response.jsonString - The json string to send back.public void sendString(io.netty.handler.codec.http.HttpResponseStatus status,
String data)
HttpRespondersendString in interface HttpResponderstatus - status of the Http response.data - string data to be sent back.public void sendString(io.netty.handler.codec.http.HttpResponseStatus status,
String data,
io.netty.handler.codec.http.HttpHeaders headers)
HttpRespondersendString in interface HttpResponderstatus - status of the Http response.data - string data to be sent back.headers - additional headers to send with the response.public void sendStatus(io.netty.handler.codec.http.HttpResponseStatus status)
HttpRespondersendStatus in interface HttpResponderstatus - status of the Http response.public void sendStatus(io.netty.handler.codec.http.HttpResponseStatus status,
io.netty.handler.codec.http.HttpHeaders headers)
HttpRespondersendStatus in interface HttpResponderstatus - status of the Http response.headers - additional headers to send with the response.public void sendByteArray(io.netty.handler.codec.http.HttpResponseStatus status,
byte[] bytes,
io.netty.handler.codec.http.HttpHeaders headers)
HttpRespondersendByteArray in interface HttpResponderstatus - status of the Http response.bytes - bytes to be sent back.headers - additional headers to send with the response.public void sendBytes(io.netty.handler.codec.http.HttpResponseStatus status,
ByteBuffer buffer,
io.netty.handler.codec.http.HttpHeaders headers)
HttpRespondersendBytes in interface HttpResponderstatus - status of the Http responsebuffer - bytes to sendheaders - additional headers to send with the response.public void sendFile(File file) throws IOException
HttpRespondersendFile in interface HttpResponderfile - The file to sendIOException - if failed to open and read the filepublic ChunkResponder sendChunkStart(io.netty.handler.codec.http.HttpResponseStatus status)
HttpResponderChunkResponder returned.sendChunkStart in interface HttpResponderstatus - the status code to respond withprotected final io.netty.handler.codec.http.HttpHeaders addContentTypeIfMissing(io.netty.handler.codec.http.HttpHeaders headers,
String contentType)
Copyright 2019 Cask, Inc. Licensed under the Apache License, Version 2.0