当前位置: 首页>>代码示例>>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;未经允许,请勿转载。