本文整理汇总了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);
}
}
示例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);
}
示例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();
}
}
示例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;
}
示例5: response
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public HttpServerResponse response() {
return response;
}
示例6: getResponse
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public HttpServerResponse getResponse() {
return response;
}
示例7: setResponse
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public void setResponse(HttpServerResponse response) {
this.response = response;
}
示例8: getResponse
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public HttpServerResponse getResponse() {
return m_request.response();
}
示例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();
}
示例10: sendResponseForbidden
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void sendResponseForbidden(HttpServerResponse response) {
response.setStatusCode(403).end();
}
示例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);
}
示例12: sendResponseNotFound
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
private void sendResponseNotFound(HttpServerResponse response) {
response.setStatusCode(404).end();
}
示例13: VertXWebdavResponse
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
public VertXWebdavResponse( final HttpServerResponse response )
{
this.response = response;
}
示例14: response
import org.vertx.java.core.http.HttpServerResponse; //导入依赖的package包/类
@Override
public HttpServerResponse response() {
return request.response();
}
示例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);
}