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 |
NanoHTTPD.Response(NanoHTTPD.Response.IStatus status, String mimeType, InputStream data, long totalBytes)
Creates a fixed length response if totalBytes>=0, otherwise chunked.
|
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.
|
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 NanoHTTPD.Response(NanoHTTPD.Response.IStatus status, String mimeType, InputStream data, long totalBytes)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
public void addHeader(String name, String value)
public 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 getHeader(String name)
public String getMimeType()
public NanoHTTPD.Method getRequestMethod()
public NanoHTTPD.Response.IStatus getStatus()
public void setGzipEncoding(boolean encodeAsGzip)
public void setKeepAlive(boolean useKeepAlive)
protected void send(OutputStream outputStream)
protected 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–2016 nanohttpd. All rights reserved.