List of usage examples for io.netty.handler.codec.http HttpResponseStatus reasonPhrase
String reasonPhrase
To view the source code for io.netty.handler.codec.http HttpResponseStatus reasonPhrase.
Click Source Link
From source file:cf.component.http.RequestException.java
License:Open Source License
public RequestException(HttpResponseStatus status) { this(status, status.reasonPhrase()); }
From source file:com.chiorichan.http.HttpResponseWrapper.java
License:Mozilla Public License
public void sendError(HttpResponseStatus status, String httpMsg, String msg) throws IOException { if (stage == HttpResponseStage.CLOSED) throw new IllegalStateException( "You can't access sendError method within this HttpResponse because the connection has been closed."); if (httpMsg == null) httpMsg = status.reasonPhrase().toString(); // NetworkManager.getLogger().info( ConsoleColor.RED + "HttpError{httpCode=" + status.code() + ",httpMsg=" + httpMsg + ",subdomain=" + request.getSubDomain() + ",domain=" + request.getDomain() + ",uri=" + request.getUri() + // ",remoteIp=" + request.getIpAddr() + "}" ); if (msg == null || msg.length() > 100) log.log(Level.SEVERE, "%s {code=%s}", httpMsg, status.code()); else// w w w. j a v a 2 s. c o m log.log(Level.SEVERE, "%s {code=%s,reason=%s}", httpMsg, status.code(), msg); resetBuffer(); // Trigger an internal Error Event to notify plugins of a possible problem. ErrorEvent event = new ErrorEvent(request, status.code(), httpMsg); EventBus.instance().callEvent(event); // TODO Make these error pages a bit more creative and/or informational to developers. if (event.getErrorHtml() != null && !event.getErrorHtml().isEmpty()) { print(event.getErrorHtml()); sendResponse(); } else { boolean printHtml = true; if (htaccess != null && htaccess.getErrorDocument(status.code()) != null) { String resp = htaccess.getErrorDocument(status.code()).getResponse(); if (resp.startsWith("/")) { sendRedirect(request.getBaseUrl() + resp); printHtml = false; } else if (resp.startsWith("http")) { sendRedirect(resp); printHtml = false; } else httpMsg = resp; } if (printHtml) { println("<html><head><title>" + status.code() + " - " + httpMsg + "</title></head><body>"); println("<h1>" + status.code() + " - " + httpMsg + "</h1>"); if (msg != null && !msg.isEmpty()) println("<p>" + msg + "</p>"); println("<hr>"); println("<small>Running <a href=\"https://github.com/ChioriGreene/ChioriWebServer\">" + Versioning.getProduct() + "</a> Version " + Versioning.getVersion() + " (Build #" + Versioning.getBuildNumber() + ")<br />" + Versioning.getCopyright() + "</small>"); println("</body></html>"); sendResponse(); } } }
From source file:com.chiorichan.lang.HttpError.java
License:Mozilla Public License
public HttpError(HttpResponseStatus status, String msg) { super(msg);/*from w ww. j av a 2 s .c om*/ this.reason = status.reasonPhrase().toString(); this.status = status; }
From source file:com.github.thinker0.mesos.MesosHealthCheckerServer.java
License:Apache License
/** * Writes a HTTP error response.//w w w .jav a 2s .co m * * @param ctx The channel context. * @param request The HTTP request. * @param status The error status. */ private void writeErrorResponse(final ChannelHandlerContext ctx, final FullHttpRequest request, final HttpResponseStatus status) { writeResponse(ctx, request, status, TYPE_PLAIN, status.reasonPhrase()); }
From source file:com.groupon.vertx.utils.HealthcheckHandler.java
License:Apache License
protected void processHeartBeatResponse(Boolean exists, HttpServerRequest request, long startTime) { HttpResponseStatus status; final boolean includeBody = !request.method().equals(HttpMethod.HEAD); if (exists) { status = HttpResponseStatus.OK;/* ww w. ja v a2s . c om*/ } else { status = HttpResponseStatus.SERVICE_UNAVAILABLE; } setCommonHttpResponse(request, status); String responseBody = status.reasonPhrase(); if (includeBody) { request.response().end(responseBody); } else { request.response().putHeader(HttpHeaderNames.CONTENT_LENGTH, Integer.toString(responseBody.length())); request.response().end(); } long totalTime = System.currentTimeMillis() - startTime; LOG.debug("handle", "healthcheckResponse", new String[] { "method", "status", "totalTime" }, request.method(), status.code(), totalTime); }
From source file:com.groupon.vertx.utils.HealthcheckHandler.java
License:Apache License
protected void processExceptionResponse(HttpServerRequest request, Exception ex, long startTime) { HttpResponseStatus status = HttpResponseStatus.SERVICE_UNAVAILABLE; final boolean includeBody = !request.method().equals(HttpMethod.HEAD); String responseBody = status.reasonPhrase() + ": " + ex.getMessage(); setCommonHttpResponse(request, status); if (includeBody) { request.response().end(responseBody); } else {// w ww . j a v a 2 s. c o m request.response().putHeader(HttpHeaderNames.CONTENT_LENGTH, Integer.toString(responseBody.length())); request.response().end(); } long totalTime = System.currentTimeMillis() - startTime; LOG.debug("handle", "healthcheckResponse", new String[] { "method", "status", "totalTime" }, request.method(), status.code(), totalTime); }
From source file:com.groupon.vertx.utils.HealthcheckHandler.java
License:Apache License
private void setCommonHttpResponse(HttpServerRequest request, HttpResponseStatus status) { request.response().putHeader(HttpHeaderNames.CONTENT_TYPE, CONTENT_TYPE); request.response().putHeader(HttpHeaderNames.CACHE_CONTROL, CACHE_CONTROL); request.response().setStatusCode(status.code()); request.response().setStatusMessage(status.reasonPhrase()); }
From source file:com.netflix.prana.internal.DefaultContext.java
License:Apache License
@Override public Observable<Void> sendError(final HttpResponseStatus status, final String message) { Map<String, String> messageObject = new HashMap<String, String>() { {//from ww w . j a v a 2 s . com put("reason", status.reasonPhrase()); put("message", message); } }; return sendJson(messageObject); }
From source file:com.spotify.ffwd.http.HttpException.java
License:Apache License
public HttpException(final HttpResponseStatus status) { super(status.reasonPhrase()); this.status = status; }
From source file:com.strategicgains.restexpress.plugin.metrics.MetricsPlugin.java
License:Apache License
private String getResponseCounterName(HttpResponseStatus responseStatus) { return responseStatus.code() + "-" + responseStatus.reasonPhrase() + "-count"; }