本文整理了Java中org.simpleframework.http.Response.setStatus
方法的一些代码示例,展示了Response.setStatus
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setStatus
方法的具体详情如下:
包路径:org.simpleframework.http.Response
类名称:Response
方法名:setStatus
暂无
代码示例来源:origin: org.simpleframework/simple-http
/**
* This is used to set the status code and description
* for this response. Setting the code and description in
* this manner provides a much more convenient way to set
* the response status line details.
*
* @param status this is the status to set on the response
*/
public void setStatus(Status status) {
response.setStatus(status);
}
代码示例来源:origin: org.simpleframework/simple
/**
* This is used to set the status code and description
* for this response. Setting the code and description in
* this manner provides a much more convenient way to set
* the response status line details.
*
* @param status this is the status to set on the response
*/
public void setStatus(Status status) {
response.setStatus(status);
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to set the status code and description
* for this response. Setting the code and description in
* this manner provides a much more convenient way to set
* the response status line details.
*
* @param status this is the status to set on the response
*/
public void setStatus(Status status) {
response.setStatus(status);
}
代码示例来源:origin: CodeStory/fluent-http
@Override
public void setStatus(int statusCode) {
response.setStatus(Status.getStatus(statusCode));
}
代码示例来源:origin: tdelenikas/smslib
response.setStatus(s);
else response.setStatus(Status.FORBIDDEN);
else response.setStatus(Status.NOT_FOUND);
response.close();
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to respond to the client with a HTTP 400 response
* indicating the WebSocket handshake failed. No response body is
* sent with the rejection message and the underlying TCP channel
* is closed to prevent further use of the connection.
*/
private void reject() throws IOException {
long time = System.currentTimeMillis();
response.setStatus(Status.BAD_REQUEST);
response.setValue(CONNECTION, CLOSE);
response.setDate(DATE, time);
String header = response.toString();
byte[] message = header.getBytes("UTF-8");
trace.trace(WRITE_HEADER, header);
writer.write(message);
writer.flush();
writer.close();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This is used to respond to the client with a HTTP 400 response
* indicating the WebSocket handshake failed. No response body is
* sent with the rejection message and the underlying TCP channel
* is closed to prevent further use of the connection.
*/
private void reject() throws IOException {
long time = System.currentTimeMillis();
response.setStatus(Status.BAD_REQUEST);
response.setValue(CONNECTION, CLOSE);
response.setDate(DATE, time);
String header = response.toString();
byte[] message = header.getBytes("UTF-8");
trace.trace(WRITE_HEADER, header);
writer.write(message);
writer.flush();
writer.close();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This is used to respond to the client with a HTTP 101 response
* to indicate that the WebSocket handshake succeeeded. Once this
* response has been sent all traffic between the client and
* server will be with WebSocket frames as defined by RFC 6455.
*/
private void accept() throws IOException {
long time = System.currentTimeMillis();
String accept = token.create();
response.setStatus(Status.SWITCHING_PROTOCOLS);
response.setDescription(UPGRADE);
response.setValue(CONNECTION, UPGRADE);
response.setDate(DATE, time);
response.setValue(SEC_WEBSOCKET_ACCEPT, accept);
response.setValue(UPGRADE, WEBSOCKET);
String header = response.toString();
byte[] message = header.getBytes("UTF-8");
trace.trace(WRITE_HEADER, header);
writer.write(message);
writer.flush();
}
}
代码示例来源: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: org.simpleframework/simple-http
/**
* This is used to respond to the client with a HTTP 101 response
* to indicate that the WebSocket handshake succeeeded. Once this
* response has been sent all traffic between the client and
* server will be with WebSocket frames as defined by RFC 6455.
*/
private void accept() throws IOException {
long time = System.currentTimeMillis();
String accept = token.create();
response.setStatus(Status.SWITCHING_PROTOCOLS);
response.setDescription(UPGRADE);
response.setValue(CONNECTION, UPGRADE);
response.setDate(DATE, time);
response.setValue(SEC_WEBSOCKET_ACCEPT, accept);
response.setValue(UPGRADE, WEBSOCKET);
String header = response.toString();
byte[] message = header.getBytes("UTF-8");
trace.trace(WRITE_HEADER, header);
writer.write(message);
writer.flush();
}
}
代码示例来源:origin: lantunes/fixd
subscriberResponse.setStatus(Status.REQUEST_TIMEOUT);
subscriberResponse.getPrintStream().close();
break;
代码示例来源: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);
}
}
}
代码示例来源:origin: lantunes/fixd
response.setStatus(resolved.errorStatus);
sendAndCommitResponse(response, responseContentType, responseBody);
return;
response.setStatus(Status.INTERNAL_SERVER_ERROR);
sendAndCommitResponse(response, "text/plain", new StringResponseBody(""));
内容来源于网络,如有侵权,请联系作者删除!