use of org.vertx.java.core.http.HttpServerResponse in project fabric8 by jboss-fuse.
the class HttpGatewayHandler method doReturnIndex.
protected void doReturnIndex(HttpServerRequest request, Map<String, MappedServices> mappingRules) throws IOException {
String json = mappingRulesToJson(mappingRules);
HttpServerResponse response = request.response();
response.headers().set(CONTENT_TYPE, "application/json");
if ("HEAD".equals(request.method())) {
// For HEAD method you must not return message body but must send 'Content-Length' header
// https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
String contentLength = String.valueOf(new Buffer(json).length());
response.putHeader(CONTENT_LENGTH, contentLength).end();
} else {
response.end(json);
}
response.setStatusCode(200);
}
Aggregations