本文整理了Java中org.simpleframework.http.Response.setContentType
方法的一些代码示例,展示了Response.setContentType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setContentType
方法的具体详情如下:
包路径:org.simpleframework.http.Response
类名称:Response
方法名:setContentType
[英]This is used to set the content type for the response. Typically a response will contain a message body of some sort. This is used to conveniently set the type for that response. Setting the content type can also be done explicitly if desired.
[中]这用于设置响应的内容类型。通常,响应将包含某种消息体。这用于方便地设置该响应的类型。如果需要,也可以显式设置内容类型。
代码示例来源:origin: org.simpleframework/simple
/**
* This is used to set the content type for the response. Typically
* a response will contain a message body of some sort. This is used
* to conveniently set the type for that response. Setting the
* content type can also be done explicitly if desired.
*
* @param type this is the type that is to be set in the response
*/
public void setContentType(String type) {
response.setContentType(type);
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This is used to set the content type for the response. Typically
* a response will contain a message body of some sort. This is used
* to conveniently set the type for that response. Setting the
* content type can also be done explicitly if desired.
*
* @param type this is the type that is to be set in the response
*/
public void setContentType(String type) {
response.setContentType(type);
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to set the content type for the response. Typically
* a response will contain a message body of some sort. This is used
* to conveniently set the type for that response. Setting the
* content type can also be done explicitly if desired.
*
* @param type this is the type that is to be set in the response
*/
public void setContentType(String type) {
response.setContentType(type);
}
代码示例来源:origin: opendedup/sdfs
private void downloadFile(File f, Request request, Response response) throws IOException {
if (f.exists()) {
response.setContentType("application/octet-stream");
response.addValue("Server", "SDFS Management Server");
response.setContentLength(f.length());
InputStream in = new FileInputStream(f);
OutputStream out = response.getOutputStream();
byte[] buf = new byte[32768];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
out.flush();
in.close();
out.close();
} else {
response.setCode(404);
PrintStream body = response.getPrintStream();
body.println("could not find " + f.getPath());
body.close();
SDFSLogger.getLog().warn("unable to find " + f.getPath());
}
}
代码示例来源:origin: opendedup/sdfs
rsp.setContentType("text/xml");
byte[] rb = rsString.getBytes();
rsp.setContentLength(rb.length);
代码示例来源:origin: opendedup/sdfs
rsp.setContentType("application/octet-stream");
rsp.addValue("Server", "SDFS Management Server");
rsp.setDate("Date", time);
rsp.setContentType("text/xml");
byte[] rb = rsString.getBytes();
rsp.setContentLength(rb.length);
代码示例来源:origin: opendedup/sdfs
rsp.setContentType("text/xml");
byte[] rb = rsString.getBytes();
rsp.setContentLength(rb.length);
代码示例来源:origin: zanata/zanata-platform
@Override
public void handle(Request request, Response response) {
try {
PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.setStatus(status);
response.setContentType("text/plain");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
log.info("mock container returning: status [{}], content [{}]",
status, responseContent);
body.println(responseContent);
body.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: opendedup/sdfs
response.setContentType("text/xml");
byte[] rb = rsString.getBytes();
response.setContentLength(rb.length);
byte[] rslt = new BatchGetBlocksCmd().getResult(rb);
long time = System.currentTimeMillis();
response.setContentType("application/octet-stream");
response.setValue("Server", "SDFS Management Server");
response.setDate("Date", time);
response.setContentType("text/xml");
byte[] rb = rsString.getBytes();
response.setContentLength(rb.length);
} else {
long time = System.currentTimeMillis();
response.setContentType("application/json");
response.setValue("Server", "SDFS Management Server");
response.setDate("Date", time);
byte[] data = HCServiceProxy.fetchHashChunk(hash).getData();
long time = System.currentTimeMillis();
response.setContentType("application/octet-stream");
response.setValue("Server", "SDFS Management Server");
response.setDate("Date", time);
byte[] rslt = new BatchGetBlocksCmd().getResult(rb);
long time = System.currentTimeMillis();
response.setContentType("application/octet-stream");
代码示例来源:origin: zanata/zanata-platform
@Override
public void handle(Request request, Response response) {
try {
PrintStream body = response.getPrintStream();
long time = System.currentTimeMillis();
response.setValue("Content-Type", "text/plain");
response.setContentType("application/xml;charset=utf-8");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
String path = request.getAddress().getPath().getPath();
log.trace("request path is {}", path);
StatusAndContent statusAndContent = tryMatchPath(path);
Status status = statusAndContent.status;
response.setStatus(status);
String content = statusAndContent.content;
log.trace("mock container returning: status [{}], content [{}]",
status, content);
body.println(content);
body.close();
} catch (Exception e) {
e.printStackTrace();
response.setStatus(Status.INTERNAL_SERVER_ERROR);
try {
response.close();
} catch (IOException e1) {
throw new RuntimeException(e1);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!