本文整理汇总了Java中fi.iki.elonen.NanoHTTPD.Response.IStatus类的典型用法代码示例。如果您正苦于以下问题:Java IStatus类的具体用法?Java IStatus怎么用?Java IStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IStatus类属于fi.iki.elonen.NanoHTTPD.Response包,在下文中一共展示了IStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newFixedLengthResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Create a text response with known length.
*/
public static Response newFixedLengthResponse(IStatus status, String mimeType, String txt) {
ContentType contentType = new ContentType(mimeType);
if (txt == null) {
return newFixedLengthResponse(status, mimeType, new ByteArrayInputStream(new byte[0]), 0);
} else {
byte[] bytes;
try {
CharsetEncoder newEncoder = Charset.forName(contentType.getEncoding()).newEncoder();
if (!newEncoder.canEncode(txt)) {
contentType = contentType.tryUTF8();
}
bytes = txt.getBytes(contentType.getEncoding());
} catch (UnsupportedEncodingException e) {
NanoHTTPD.LOG.log(Level.SEVERE, "encoding problem, responding nothing", e);
bytes = new byte[0];
}
return newFixedLengthResponse(status, contentType.getContentTypeHeader(), new ByteArrayInputStream(bytes), bytes.length);
}
}
示例2: Response
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Creates a fixed length response if totalBytes>=0, otherwise chunked.
*/
protected Response(IStatus status, String mimeType, InputStream data, long totalBytes) {
this.status = status;
this.mimeType = mimeType;
if (data == null) {
this.data = new ByteArrayInputStream(new byte[0]);
this.contentLength = 0L;
} else {
this.data = data;
this.contentLength = totalBytes;
}
this.chunkedTransfer = this.contentLength < 0;
keepAlive = true;
}
示例3: render
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public Response render(ModelAndView model) {
IStatus status;
if (model.getStatus() != null) {
status = model.getStatus();
} else {
status = Status.OK;
}
return NanoHTTPD.newFixedLengthResponse(status, MimeType.JSON.getType(), model.getData());
}
示例4: Response
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Creates a fixed length response if totalBytes>=0, otherwise chunked.
*/
public Response(IStatus status, String mimeType, InputStream data, long totalBytes) {
this.status = status;
this.mimeType = mimeType;
if (data == null) {
this.data = new ByteArrayInputStream(new byte[0]);
this.contentLength = 0L;
} else {
this.data = data;
this.contentLength = totalBytes;
}
this.chunkedTransfer = this.contentLength < 0;
keepAlive = true;
}
示例5: newFixedLengthResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Create a text response with known length.
*/
public Response newFixedLengthResponse(IStatus status, String mimeType, String txt) {
if (txt == null) {
return newFixedLengthResponse(status, mimeType, new ByteArrayInputStream(new byte[0]), 0);
} else {
byte[] bytes;
try {
bytes = txt.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
NanoHTTPD.LOG.log(Level.SEVERE, "encoding problem, responding nothing", e);
bytes = new byte[0];
}
return newFixedLengthResponse(status, mimeType, new ByteArrayInputStream(bytes), bytes.length);
}
}
示例6: newFixedLengthResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Create a text response with known length.
*/
public static Response newFixedLengthResponse(IStatus status, String mimeType, String txt) {
if (txt == null) {
return newFixedLengthResponse(status, mimeType, new ByteArrayInputStream(new byte[0]), 0);
} else {
byte[] bytes;
try {
bytes = txt.getBytes("UTF-8");
} catch (UnsupportedEncodingException e) {
NanoHTTPD.LOG.log(Level.SEVERE, "encoding problem, responding nothing", e);
bytes = new byte[0];
}
return newFixedLengthResponse(status, mimeType, new ByteArrayInputStream(bytes), bytes.length);
}
}
示例7: newFixedLengthResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public static Response newFixedLengthResponse(IStatus status, String mimeType, String message) {
Response response = NanoHTTPD.newFixedLengthResponse(status, mimeType, message);
response.addHeader("Accept-Ranges", "bytes");
return response;
}
示例8: getStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public IStatus getStatus() {
return this.status;
}
示例9: setStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public void setStatus(IStatus status) {
this.status = status;
}
示例10: newChunkedResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Create a response with unknown length (using HTTP 1.1 chunking).
*/
public static Response newChunkedResponse(IStatus status, String mimeType, InputStream data) {
return new Response(status, mimeType, data, -1);
}
示例11: getStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public IStatus getStatus() {
return status;
}
示例12: setStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
public void setStatus(IStatus status) {
this.status = status;
}
示例13: getStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
@Override
public IStatus getStatus() {
return Status.OK;
}
示例14: getStatus
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
@Override
public IStatus getStatus() {
return Status.NOT_ACCEPTABLE;
}
示例15: newChunkedResponse
import fi.iki.elonen.NanoHTTPD.Response.IStatus; //导入依赖的package包/类
/**
* Create a response with unknown length (using HTTP 1.1 chunking).
*/
public Response newChunkedResponse(IStatus status, String mimeType, InputStream data) {
return new Response(status, mimeType, data, -1);
}