public static boolean isError(int code) { return isClientError(code) || isServerError(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 HttpSC.isInformational(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 HttpSC.isRedirection(this._code); }
@Override protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException { if ( message == null ) message = HttpSC.getMessage(code) ; writer.write(format("Error %d: %s\n", code, message)) ; Throwable th = (Throwable)request.getAttribute("javax.servlet.error.exception"); while(th!=null) { writer.write("\n"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); th.printStackTrace(pw); pw.flush(); writer.write(sw.getBuffer().toString()); writer.write("\n"); th = th.getCause(); } } }
/** * 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 HttpSC.isClientError(this._code); }
/** * 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 HttpSC.isSuccess(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 HttpSC.isServerError(this._code); } }
/** * Get the status message for a specific code. * * @param code * the code to look up * @return the specific message, or the code number itself if code * does not match known list. */ public static String getMessage(int code) { Code codeEnum = getCode(code); if (codeEnum != null) { return codeEnum.getMessage(); } else { return Integer.toString(code); } }
@Override protected void handleErrorPage(HttpServletRequest request, Writer writer, int code, String message) throws IOException { if ( message == null ) message = HttpSC.getMessage(code) ; writer.write(format("Error %d: %s\n", code, message)) ; Throwable th = (Throwable)request.getAttribute("javax.servlet.error.exception"); while(th!=null) { writer.write("\n"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); th.printStackTrace(pw); pw.flush(); writer.write(sw.getBuffer().toString()); writer.write("\n"); th = th.getCause(); } } }
/** * 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 HttpSC.isClientError(this._code); }
/** * 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 HttpSC.isSuccess(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 HttpSC.isServerError(this._code); } }
/** * Get the status message for a specific code. * * @param code * the code to look up * @return the specific message, or the code number itself if code * does not match known list. */ public static String getMessage(int code) { Code codeEnum = getCode(code); if (codeEnum != null) { return codeEnum.getMessage(); } else { return Integer.toString(code); } }
static void printResponse(ValidationAction action) { long time = action.getTime() ; if ( action.verbose ) { // if ( action.contentType != null ) // log.info(format("[%d] %-20s %s", action.id, HttpNames.hContentType, action.contentType)) ; // if ( action.contentLength != -1 ) // log.info(format("[%d] %-20s %d", action.id, HttpNames.hContentLengh, action.contentLength)) ; // for ( Map.Entry<String, String> e: action.headers.entrySet() ) // log.info(format("[%d] %-20s %s", action.id, e.getKey(), e.getValue())) ; } String timeStr = fmtMillis(time) ; if ( action.message == null ) action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, HttpSC.getMessage(action.statusCode), timeStr)) ; else action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, action.message, timeStr)) ; }
public static boolean isError(int code) { return isClientError(code) || isServerError(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 HttpSC.isInformational(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 HttpSC.isRedirection(this._code); }
static void printResponse(ValidationAction action) { long time = action.getTime() ; if ( action.verbose ) { // if ( action.contentType != null ) // log.info(format("[%d] %-20s %s", action.id, HttpNames.hContentType, action.contentType)) ; // if ( action.contentLength != -1 ) // log.info(format("[%d] %-20s %d", action.id, HttpNames.hContentLengh, action.contentLength)) ; // for ( Map.Entry<String, String> e: action.headers.entrySet() ) // log.info(format("[%d] %-20s %s", action.id, e.getKey(), e.getValue())) ; } String timeStr = fmtMillis(time) ; if ( action.message == null ) action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, HttpSC.getMessage(action.statusCode), timeStr)) ; else action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, action.message, timeStr)) ; }
if (HttpSC.isClientError(statusCode) || HttpSC.isServerError(statusCode)) { log.debug(format("[%d] %s %s", id, statusLine.getStatusCode(), statusLine.getReasonPhrase()));
static void printResponse(ValidationAction action) { long time = action.getTime() ; if ( action.verbose ) { // if ( action.contentType != null ) // log.info(format("[%d] %-20s %s", action.id, HttpNames.hContentType, action.contentType)) ; // if ( action.contentLength != -1 ) // log.info(format("[%d] %-20s %d", action.id, HttpNames.hContentLengh, action.contentLength)) ; // for ( Map.Entry<String, String> e: action.headers.entrySet() ) // log.info(format("[%d] %-20s %s", action.id, e.getKey(), e.getValue())) ; } String timeStr = fmtMillis(time) ; if ( action.message == null ) action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, HttpSC.getMessage(action.statusCode), timeStr)) ; else action.log.info(String.format("[%d] %d %s (%s) ", action.id, action.statusCode, action.message, timeStr)) ; }