@Override protected void handleErrorPage( HttpServletRequest request, Writer writer, int code, String message) throws IOException { writer.write("<!DOCTYPE<html><head><title>Error</title></head><html><body>" + code + " - " + HttpStatus.getMessage(code) + "</body></html>"); } });
private static Code extractStatusCode(final Throwable message) { assertThat(message, is(instanceOf(UpgradeException.class))); return HttpStatus.getCode(((UpgradeException) message).getResponseStatusCode()); }
/** * Simple test against an code to determine if it falls into the * <code>Success</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Success</code> messages. */ public boolean isSuccess() { return HttpStatus.isSuccess(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Informational</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Informational</code> messages. */ public boolean isInformational() { return HttpStatus.isInformational(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Client Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Client Error</code> messages. */ public boolean isClientError() { return HttpStatus.isClientError(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Redirection</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Redirection</code> messages. */ public boolean isRedirection() { return HttpStatus.isRedirection(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Server Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Server Error</code> messages. */ public boolean isServerError() { return HttpStatus.isServerError(this._code); } }
if (HttpStatus.isSuccess(res.getStatus())) { else if (HttpStatus.isRedirection(res.getStatus())) {
/** * Simple test against an code to determine if it falls into the * <code>Success</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Success</code> messages. */ public boolean isSuccess() { return HttpStatus.isSuccess(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Informational</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Informational</code> messages. */ public boolean isInformational() { return HttpStatus.isInformational(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Client Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Client Error</code> messages. */ public boolean isClientError() { return HttpStatus.isClientError(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Redirection</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Redirection</code> messages. */ public boolean isRedirection() { return HttpStatus.isRedirection(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Server Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Server Error</code> messages. */ public boolean isServerError() { return HttpStatus.isServerError(this._code); } }
/** * Converts exception into json map. * @param ex Exception to be converted. * @param statusCode Status code to be returned. * @return Map to be converted into json. */ public static Map exceptionToJson(Exception ex, int statusCode) { StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); return ImmutableMap.of( "error", statusCode + " " + HttpStatus.getMessage(statusCode), "errorMessage", sw.toString()); }
@Override protected boolean matchesSafely( final KsqlRestException actual, final Description mismatchDescription ) { final Code actualCode = HttpStatus.getCode(actual.getResponse().getStatus()); if (!expected.matches(actualCode)) { mismatchDescription.appendText("but status code "); expected.describeMismatch(actualCode, mismatchDescription); return false; } return true; }
/** * Simple test against an code to determine if it falls into the * <code>Success</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Success</code> messages. */ public boolean isSuccess() { return HttpStatus.isSuccess(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Informational</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Informational</code> messages. */ public boolean isInformational() { return HttpStatus.isInformational(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Client Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc2616">RFC 2616 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Client Error</code> messages. */ public boolean isClientError() { return HttpStatus.isClientError(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Redirection</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Redirection</code> messages. */ public boolean isRedirection() { return HttpStatus.isRedirection(this._code); }
/** * Simple test against an code to determine if it falls into the * <code>Server Error</code> message category as defined in the <a * href="http://tools.ietf.org/html/rfc1945">RFC 1945 - HTTP/1.0</a>, * and <a href="http://tools.ietf.org/html/rfc7231">RFC 7231 - * HTTP/1.1</a>. * * @return true if within range of codes that belongs to * <code>Server Error</code> messages. */ public boolean isServerError() { return HttpStatus.isServerError(this._code); } }