当前位置: 首页>>代码示例>>Java>>正文


Java HttpServerResponse类代码示例

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


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


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