當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpResponseStatus.getReasonPhrase方法代碼示例

本文整理匯總了Java中org.jboss.netty.handler.codec.http.HttpResponseStatus.getReasonPhrase方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponseStatus.getReasonPhrase方法的具體用法?Java HttpResponseStatus.getReasonPhrase怎麽用?Java HttpResponseStatus.getReasonPhrase使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.netty.handler.codec.http.HttpResponseStatus的用法示例。


在下文中一共展示了HttpResponseStatus.getReasonPhrase方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createErrorPage

import org.jboss.netty.handler.codec.http.HttpResponseStatus; //導入方法依賴的package包/類
/**
 * Creates an error page.
 * 
 * @param status The HTTP status.
 * @param description The error description.
 * @return The error page as a buffer.
 */
private ChannelBuffer createErrorPage(HttpResponseStatus status, String description) {
	String title = status.getCode() + " " + status.getReasonPhrase();

	StringBuilder builder = new StringBuilder();

	builder.append("<!DOCTYPE html><html><head><title>");
	builder.append(title);
	builder.append("</title></head><body><h1>");
	builder.append(title);
	builder.append("</h1><p>");
	builder.append(description);
	builder.append("</p><hr /><address>");
	builder.append(SERVER_IDENTIFIER);
	builder.append(" Server</address></body></html>");

	return ChannelBuffers.copiedBuffer(builder.toString(), Charset.defaultCharset());
}
 
開發者ID:DealerNextDoor,項目名稱:ApolloDev,代碼行數:25,代碼來源:HttpRequestWorker.java

示例2: getErrorHtml

import org.jboss.netty.handler.codec.http.HttpResponseStatus; //導入方法依賴的package包/類
private String getErrorHtml(HttpResponseStatus status, Throwable throwable) {
	String stackTrace = null;
	if (throwable != null) {
		StringWriter sw = new StringWriter();
		PrintWriter s = new PrintWriter(sw);
		throwable.printStackTrace(s);
		stackTrace = sw.toString();
	}
	return "<html>\n" + "<head>\n" + "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n" + "<title>Error " + status.toString() + "</title>\n"
			+ "</head>\n" + "<body>\n" + "<h2>HTTP ERROR: " + status.getCode() + "</h2>\n" + "<p>Problem accessing [" + request.getMethod() + "]" + request.getUri()
			+ ". Reason:\n" + "<pre>    " + status.getReasonPhrase() + (stackTrace != null ? "\n\n" + stackTrace : "") + "</pre></p>\n"
			+ "<hr /><i><small>Powered by FastcatSearch</small></i>\n" + "</body>\n" + "</html>";
}
 
開發者ID:gncloud,項目名稱:fastcatsearch3,代碼行數:14,代碼來源:NettyHttpChannel.java

示例3: sendHttpResponse

import org.jboss.netty.handler.codec.http.HttpResponseStatus; //導入方法依賴的package包/類
private void sendHttpResponse(ActorRef sender, HttpResponseStatus status, String response) {

        // headers
        Map<String, List<String>> headers = new HashMap<String, List<String>>();
        headers.put(HttpHeaders.Names.CONTENT_TYPE, Arrays.asList("text/plain"));

        // response
        if (StringUtils.isEmpty(response)) {
            response = status.getReasonPhrase();
        }

        sender.tell(new HttpResponse(status.getCode(), headers,
                response.getBytes(Charset.forName("UTF-8"))), getSelf());
    }
 
開發者ID:elasticsoftwarefoundation,項目名稱:elasterix,代碼行數:15,代碼來源:UserController.java


注:本文中的org.jboss.netty.handler.codec.http.HttpResponseStatus.getReasonPhrase方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。