public static class NanoHTTPD.Response extends Object implements Closeable
| Modifier and Type | Class and Description |
|---|---|
static interface |
NanoHTTPD.Response.IStatus |
static class |
NanoHTTPD.Response.Status
Some HTTP response status codes
|
| Modifier | Constructor and Description |
|---|---|
protected |
Response(NanoHTTPD.Response.IStatus status,
String mimeType,
InputStream data,
long totalBytes)
Creates a fixed length response if totalBytes>=0, otherwise chunked.
|
protected |
Response(NanoHTTPD.Response.Status status,
String mimeType,
String data) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String name,
String value)
Adds given line to the header.
|
void |
close() |
void |
closeConnection(boolean close)
Indicate to close the connection after the Response has been sent.
|
long |
getContentLength() |
InputStream |
getData() |
String |
getHeader(String name) |
String |
getMimeType() |
NanoHTTPD.Method |
getRequestMethod() |
NanoHTTPD.Response.IStatus |
getStatus() |
boolean |
isCloseConnection() |
protected void |
printHeader(PrintWriter pw,
String key,
String value) |
protected void |
send(OutputStream outputStream)
Sends given response to the socket.
|
protected long |
sendContentLengthHeaderIfNotAlreadyPresent(PrintWriter pw,
long defaultSize) |
void |
setChunkedTransfer(boolean chunkedTransfer) |
void |
setData(InputStream data) |
void |
setGzipEncoding(boolean encodeAsGzip) |
void |
setKeepAlive(boolean useKeepAlive) |
void |
setMimeType(String mimeType) |
void |
setRequestMethod(NanoHTTPD.Method requestMethod) |
void |
setStatus(NanoHTTPD.Response.IStatus status) |
protected Response(NanoHTTPD.Response.Status status, String mimeType, String data)
protected Response(NanoHTTPD.Response.IStatus status, String mimeType, InputStream data, long totalBytes)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic void closeConnection(boolean close)
close - true to hint connection closing, false to let connection be closed by client.public boolean isCloseConnection()
true if connection is to be closed after this Response has been sent.public InputStream getData()
public String getMimeType()
public NanoHTTPD.Method getRequestMethod()
public NanoHTTPD.Response.IStatus getStatus()
public long getContentLength()
public void setGzipEncoding(boolean encodeAsGzip)
public void setKeepAlive(boolean useKeepAlive)
protected void send(OutputStream outputStream) throws IOException
IOExceptionprotected void printHeader(PrintWriter pw, String key, String value)
protected long sendContentLengthHeaderIfNotAlreadyPresent(PrintWriter pw, long defaultSize)
public void setChunkedTransfer(boolean chunkedTransfer)
public void setData(InputStream data)
public void setMimeType(String mimeType)
public void setRequestMethod(NanoHTTPD.Method requestMethod)
public void setStatus(NanoHTTPD.Response.IStatus status)
Copyright © 2012–2020. All rights reserved.