本文整理了Java中org.eclipse.jetty.server.Response.setStatus
方法的一些代码示例,展示了Response.setStatus
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setStatus
方法的具体详情如下:
包路径:org.eclipse.jetty.server.Response
类名称:Response
方法名:setStatus
暂无
代码示例来源:origin: jooby-project/jooby
@Override
protected void handshake(final Runnable handler) throws Exception {
/** Infinite timeout because the continuation is never resumed but only completed on close. */
req.getAsyncContext().setTimeout(0L);
/** Server sent events headers. */
rsp.setStatus(HttpServletResponse.SC_OK);
rsp.setHeader("Connection", "Close");
rsp.setContentType("text/event-stream; charset=utf-8");
rsp.flushBuffer();
HttpChannel channel = rsp.getHttpChannel();
Connector connector = channel.getConnector();
Executor executor = connector.getExecutor();
executor.execute(handler);
}
代码示例来源:origin: jersey/jersey
@Override
public void failure(final Throwable error) {
try {
if (!response.isCommitted()) {
try {
if (configSetStatusOverSendError) {
response.reset();
//noinspection deprecation
response.setStatus(INTERNAL_SERVER_ERROR, "Request failed.");
} else {
response.sendError(INTERNAL_SERVER_ERROR, "Request failed.");
}
} catch (final IllegalStateException ex) {
// a race condition externally committing the response can still occur...
LOGGER.log(Level.FINER, "Unable to reset failed response.", ex);
} catch (final IOException ex) {
throw new ContainerException(LocalizationMessages.EXCEPTION_SENDING_ERROR_RESPONSE(INTERNAL_SERVER_ERROR,
"Request failed."), ex);
}
}
} finally {
LOGGER.log(Level.FINEST, "failure(...) called");
commit();
rethrow(error);
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
public void setStatus(int sc)
{
setStatus(sc,null);
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus
public void setStatus(int sc)
{
setStatus(sc,null);
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server
public void setStatus(int sc)
{
setStatus(sc,null);
}
代码示例来源:origin: org.eclipse.jetty/server
public void setStatus(int sc)
{
setStatus(sc,null);
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp
public void setStatus(int sc)
{
setStatus(sc,null);
}
代码示例来源:origin: com.github.tomakehurst/wiremock-jre8
@Override
public void malformedResponseChunk() {
try {
response.setStatus(200);
response.flushBuffer();
socket.getChannel().write(BufferUtil.toBuffer(GARBAGE));
socket.close();
} catch (IOException e) {
throwUnchecked(e);
}
}
代码示例来源:origin: com.github.tomakehurst/wiremock-jre8
@Override
public void malformedResponseChunk() {
try {
response.setStatus(200);
response.flushBuffer();
writeGarbageThenCloseSocket();
} catch (IOException e) {
throwUnchecked(e);
}
}
代码示例来源:origin: stackoverflow.com
response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
return Filter.STOP;
代码示例来源:origin: jenkinsci/winstone
private void minimalErrorResponse(Throwable failure)
{
try
{
int code = 500;
Integer status=(Integer)_request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE);
if (status!=null)
code = status.intValue();
else
{
Throwable cause = unwrap(failure,BadMessageException.class);
if (cause instanceof BadMessageException)
code = ((BadMessageException)cause).getCode();
}
_response.reset(true);
_response.setStatus(code);
_response.flushBuffer();
}
catch (Throwable x)
{
if (x != failure)
failure.addSuppressed(x);
abort(failure);
}
}
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
complete();
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
complete();
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
complete();
代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-server
setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY);
complete();
代码示例来源:origin: jenkinsci/winstone
setStatus(code);
closeOutput();
代码示例来源:origin: org.jooby/jooby-jetty
@Override
protected void handshake(final Runnable handler) throws Exception {
/** Infinite timeout because the continuation is never resumed but only completed on close. */
req.getAsyncContext().setTimeout(0L);
/** Server sent events headers. */
rsp.setStatus(HttpServletResponse.SC_OK);
rsp.setHeader("Connection", "Close");
rsp.setContentType("text/event-stream; charset=utf-8");
rsp.flushBuffer();
HttpChannel channel = rsp.getHttpChannel();
Connector connector = channel.getConnector();
Executor executor = connector.getExecutor();
executor.execute(handler);
}
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
protected void handleOptions(Request request,Response response) throws IOException
{
if (!HttpMethod.OPTIONS.is(request.getMethod()))
response.sendError(HttpStatus.BAD_REQUEST_400);
request.setHandled(true);
response.setStatus(200);
response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS");
response.setContentLength(0);
response.complete();
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
protected void handleOptions(Request request,Response response) throws IOException
{
if (!HttpMethod.OPTIONS.is(request.getMethod()))
response.sendError(HttpStatus.BAD_REQUEST_400);
request.setHandled(true);
response.setStatus(200);
response.getHttpFields().put(HttpHeader.ALLOW,"GET,POST,HEAD,OPTIONS");
response.setContentLength(0);
response.complete();
}
代码示例来源:origin: org.restlet.jee/org.restlet.ext.jetty
@Override
public void sendResponse(Response response) throws IOException {
// Add call headers
Parameter header;
for (final Iterator<Parameter> iter = getResponseHeaders().iterator(); iter
.hasNext();) {
header = iter.next();
getConnection().getResponse().addHeader(header.getName(),
header.getValue());
}
// Set the status code in the response. We do this after adding the
// headers because when we have to rely on the 'sendError' method,
// the Servlet containers are expected to commit their response.
if (Status.isError(getStatusCode()) && (response.getEntity() == null)) {
try {
getConnection().getResponse().sendError(getStatusCode(),
getReasonPhrase());
} catch (IOException ioe) {
getLogger().log(Level.WARNING,
"Unable to set the response error status", ioe);
}
} else {
// Send the response entity
getConnection().getResponse().setStatus(getStatusCode());
super.sendResponse(response);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!