• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpServerResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.vertx.java.core.http.HttpServerResponse的典型用法代码示例。如果您正苦于以下问题:Java HttpServerResponse类的具体用法?Java HttpServerResponse怎么用?Java HttpServerResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpServerResponse类属于org.vertx.java.core.http包,在下文中一共展示了HttpServerResponse类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handle

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public void handle(HttpServerRequest req) {
    String resourcePath = req.path();
    HttpServerResponse response = req.response();

    if (shouldRedirectToIndexHtml(resourcePath)) {
        redirectToIndexHtml(response);
        return;
    }

    if (!isLegalResource(resourcePath)) {
        sendResponseForbidden(response);
        return;
    }

    if (!writeResourceToResponse(response, resourcePath)) {
        sendResponseNotFound(response);
    }

}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:21,代码来源:EmulatorLaunchpad.java


示例2: main

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public static void main(String[] args) {
	Handler<HttpServerRequest> handler = new Handler<HttpServerRequest>() {
		public void handle(HttpServerRequest request) {
			String path = request.absoluteURI().getPath();
			HttpServerResponse response = request.response();
			if (path.equals("/cmd/kill")) {
				response.end("Exiting...");
				SimpleHttpServer.shutdown();
				return;
			} else if (path.equals("/cmd/ping")) {
				response.end("PONG");
				return;
			}
			Person person = new Person("Netty Http Server");
			response.end("Hello, welcome you to "+person);
		}
	};
	String host = "localhost";
	int port = 9999;
	SimpleHttpServer httpServer = new SimpleHttpServer();
	httpServer.registerHttpHandler(host, port, handler);
}
 
开发者ID:trieu,项目名称:netty-with-gradle,代码行数:23,代码来源:MainApp.java


示例3: close

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public synchronized void close()
    throws IOException
{
    flush();
    super.close();
    if ( response instanceof HttpServerResponse )
    {
        try
        {
            ( (HttpServerResponse) response ).end();
        }
        catch ( final IllegalStateException e )
        {

        }
    }
    else if ( response instanceof AsyncFile )
    {
        ( (AsyncFile) response ).close();
    }
}
 
开发者ID:jdcasey,项目名称:vabr,代码行数:23,代码来源:VertXOutputStream.java


示例4: writeResourceToResponse

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private boolean writeResourceToResponse(HttpServerResponse response, String resourcePath) {
    setResponseContentType(response, resourcePath);
    byte[] bytes = readResource(resourcePath);
    if (bytes == null) {
        return false;
    }
    Buffer buffer = new Buffer(bytes);
    response.end(buffer);
    return true;
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:11,代码来源:EmulatorLaunchpad.java


示例5: response

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public HttpServerResponse response() {
    return response;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:5,代码来源:StubHttpServletRequest.java


示例6: getResponse

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public HttpServerResponse getResponse() {
    return response;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:4,代码来源:StubHttpServletRequest.java


示例7: setResponse

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public void setResponse(HttpServerResponse response) {
    this.response = response;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:4,代码来源:StubHttpServletRequest.java


示例8: getResponse

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public HttpServerResponse getResponse() {
    return m_request.response();
}
 
开发者ID:clidev,项目名称:spike.x,代码行数:4,代码来源:HttpResponse.java


示例9: redirectToIndexHtml

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void redirectToIndexHtml(HttpServerResponse response) {
    response.headers().add("Location", WEB_RESOURCES_PREFIX + "/index.html");
    response.setStatusCode(301).end();
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:5,代码来源:EmulatorLaunchpad.java


示例10: sendResponseForbidden

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void sendResponseForbidden(HttpServerResponse response) {
    response.setStatusCode(403).end();
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:4,代码来源:EmulatorLaunchpad.java


示例11: setResponseContentType

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void setResponseContentType(HttpServerResponse response, String resourcePath) {
    String contentType = findContentType(resourcePath);
    response.headers().add("Content-Type", contentType);
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:5,代码来源:EmulatorLaunchpad.java


示例12: sendResponseNotFound

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void sendResponseNotFound(HttpServerResponse response) {
    response.setStatusCode(404).end();
}
 
开发者ID:OlivierCroisier,项目名称:LP4J,代码行数:4,代码来源:EmulatorLaunchpad.java


示例13: VertXWebdavResponse

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public VertXWebdavResponse( final HttpServerResponse response )
{
    this.response = response;
}
 
开发者ID:Commonjava,项目名称:webdav-handler,代码行数:5,代码来源:VertXWebdavResponse.java


示例14: response

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public HttpServerResponse response() {
	return request.response();
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:5,代码来源:WrappedHttpServerRequest.java


示例15: gridfsSendFile

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public static void gridfsSendFile(final String id, final String downloadName, final EventBus eb,
		final String gridfsAddress, final HttpServerResponse response, final boolean inline,
		final JsonObject metadata) {
	gridfsSendFile(id, downloadName, eb, gridfsAddress, response, inline, metadata, null);
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:6,代码来源:FileUtils.java


示例16: addHeader

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public static void addHeader(HttpServerResponse response, String fileId) {
	response.headers().add("ETag", fileId);
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:4,代码来源:ETag.java


示例17: addLastModifiedHeader

import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public static void addLastModifiedHeader(HttpServerResponse response, Date resourceLastModified) {
	response.headers().add("Last-Modified", format.format(resourceLastModified));
}
 
开发者ID:web-education,项目名称:web-utils,代码行数:4,代码来源:StaticResource.java



注:本文中的org.vertx.java.core.http.HttpServerResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TObjectIntIterator类代码示例发布时间:2022-05-22
下一篇:
Java AboutHandler类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap