本文整理了Java中org.simpleframework.http.Response.set
方法的一些代码示例,展示了Response.set
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.set
方法的具体详情如下:
包路径:org.simpleframework.http.Response
类名称:Response
方法名:set
[英]This should be used when the size of the message body is known. This ensures that Persistent HTTP (PHTTP) connections can be maintained for both HTTP/1.0 and HTTP/1.1 clients. If the length of the output is not known HTTP/1.0 clients will require a connection close, which reduces performance (see RFC 2616).
This removes any previous Content-Length headers from the message header. This will then set the appropriate Content-Length header with the correct length. If a the Connection header is set with the close token then the semantics of the connection are such that the server will close it once the output stream or request is closed.
[中]当消息正文的大小已知时,应使用此选项。这确保了HTTP/1.0和HTTP/1.1客户端都可以保持持久HTTP(PHTTP)连接。如果输出的长度未知,HTTP/1.0客户端将需要关闭连接,这会降低性能(请参阅RFC 2616)。
这将从消息头中删除任何以前的内容长度头。然后,这将使用正确的长度设置适当的内容长度标题。如果使用close标记设置了连接头,那么连接的语义是,一旦输出流或请求关闭,服务器就会关闭它。
代码示例来源:origin: mpetazzoni/ttorrent
body = response.getOutputStream();
response.set("Content-Type", "text/plain");
response.set("Server", "");
response.setDate("Date", System.currentTimeMillis());
代码示例来源:origin: SonarSource/sonarqube
throw new IllegalStateException("Should accept gzip");
resp.set("Content-Encoding", "gzip");
GZIPOutputStream gzipOutputStream = new GZIPOutputStream(resp.getOutputStream());
gzipOutputStream.write("GZIP response".getBytes());
代码示例来源:origin: miltonio/milton2
@Override
public void setNonStandardHeader(String code, String value) {
headers.put( code, value);
baseResponse.set(code, value);
}
代码示例来源:origin: openpreserve/pagelyzer
if(path.getPath().substring(path.getPath().length()-3).equals("css")) contentType = "text/css";
response.set("Content-Type", contentType);
response.set("Server", "ServerLyzer/1.0 (Simple 4.0)");
response.setDate("Date", time);
response.setDate("Last-Modified", time);
代码示例来源:origin: kristofa/mock-http-server
private void errorResponse(final Response response, final int httpCode, final String message) {
response.setCode(httpCode);
response.set(CONTENT_TYPE, "text/plain;charset=utf-8");
PrintStream body;
try {
body = response.getPrintStream();
body.print(message);
body.close();
} catch (final IOException e) {
throw new IllegalStateException("Exception when building response.", e);
}
}
代码示例来源:origin: kristofa/mock-http-server
response.set("Content-Type", expectedResponse.getContentType());
LOGGER.error("Did receive an unexpected request:" + receivedRequest);
response.setCode(noMatchFoundResponseCode);
response.set("Content-Type", "text/plain;charset=utf-8");
PrintStream body;
try {
代码示例来源:origin: kristofa/mock-http-server
response.set(CONTENT_TYPE, forwardResponse.getContentType());
final OutputStream outputStream = response.getOutputStream();
try {
内容来源于网络,如有侵权,请联系作者删除!