Package org.vertx.java.core.http

Examples of org.vertx.java.core.http.HttpServerResponse


    this.manager = manager;
  }

  public void handle(ClientData clientData) {
    HttpServerRequest req = clientData.getRequest();
    HttpServerResponse res = req.response();
    String requestedFileName = clientData.getPath();
    String resourceRootDir = getRootDir();

    File rootDir = new File(requestedFileName);
    if(!rootDir.exists()) {
      copyFilesToDir();
    }

        switch (requestedFileName) {
            case "/static/flashsocket/WebSocketMainInsecure.swf":
                res.sendFile(resourceRootDir + "/WebSocketMainInsecure.swf");

                break;
            case "/static/flashsocket/WebSocketMain.swf":
                res.sendFile(resourceRootDir + "/WebSocketMain.swf");

                break;
            case "/socket.io.js":
                res.sendFile(resourceRootDir + "/socket.io.js");

                break;
            case "/socket.io.min.js":
                res.sendFile(resourceRootDir + "/socket.io.min.js");

                break;
            default:
                throw new IllegalArgumentException(requestedFileName);
        }
    res.close();
  }
View Full Code Here


     * {@inheritDoc}
     */
    @Override
    public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException {
        jerseyResponse = responseContext;
        HttpServerResponse response = vertxRequest.response();

        // Write the status
        response.setStatusCode(responseContext.getStatus());
        response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase());

        // Set the content length header
        if (contentLength != -1) {
            response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength));
        }

        for (final Map.Entry<String, List<Object>> e : responseContext.getHeaders().entrySet()) {
            for (final Object value : e.getValue()) {
                response.putHeader(e.getKey(), String.valueOf(value));
            }
        }

        // Run any response processors
        if (!responseProcessors.isEmpty()) {
            for (VertxResponseProcessor processor : responseProcessors) {
                processor.process(response, responseContext);
            }
        }

        // Return output stream based on whether entity is chunked
        if (responseContext.isChunked()) {
            response.setChunked(true);
            return new VertxChunkedOutputStream(response);
        } else {
            return new VertxOutputStream(response);
        }
    }
View Full Code Here

     */
    @Override
    public void failure(Throwable error) {

        container.logger().error(error.getMessage(), error);
        HttpServerResponse response = vertxRequest.response();

        // Set error status and end
        Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
        response.setStatusCode(status.getStatusCode());
        response.setStatusMessage(status.getReasonPhrase());
        response.end();

    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException {
        HttpServerResponse response = vertxRequest.response();

        // Write the status
        response.setStatusCode(responseContext.getStatus());
        response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase());

        // Set the content length header
        if (contentLength != -1) {
            response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength));
        }

        for (final Map.Entry<String, List<Object>> e : responseContext.getHeaders().entrySet()) {
            for (final Object value : e.getValue()) {
                response.putHeader(e.getKey(), String.valueOf(value));
            }
        }

        // Run any response processors
        for (VertxResponseProcessor processor : responseProcessors) {
            processor.process(response, responseContext);
        }

        // Return output stream based on whether entity is chunked
        if (responseContext.isChunked()) {
            response.setChunked(true);
            return new VertxChunkedOutputStream(response);
        } else {
            return new VertxOutputStream(response);
        }
    }
View Full Code Here

     */
    @Override
    public void failure(Throwable error) {

        container.logger().error(error.getMessage(), error);
        HttpServerResponse response = vertxRequest.response();

        // Set error status and end
        Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
        response.setStatusCode(status.getStatusCode());
        response.setStatusMessage(status.getReasonPhrase());
        response.end();

    }
View Full Code Here

        Map<String, MappedServices> mappingRules = httpGateway.getMappedServices();
        try {
            if (isMappingIndexRequest(request)) {
                // lets return the JSON of all the results
                String json = mappingRulesToJson(mappingRules);
                HttpServerResponse response = request.response();
                response.headers().set("ContentType", "application/json");
                response.end(json);
                response.setStatusCode(200);
            } else {
                MappedServices mappedServices = null;
                URL clientURL = null;
                Set<Map.Entry<String, MappedServices>> entries = mappingRules.entrySet();
                for (Map.Entry<String, MappedServices> entry : entries) {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    @Override
    public OutputStream writeResponseStatusAndHeaders(long contentLength, ContainerResponse responseContext) throws ContainerException {
        HttpServerResponse response = vertxRequest.response();

        // Write the status
        response.setStatusCode(responseContext.getStatus());
        response.setStatusMessage(responseContext.getStatusInfo().getReasonPhrase());

        // Set the content length header
        if (contentLength != -1) {
            response.putHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(contentLength));
        }

        for (final Map.Entry<String, List<Object>> e : responseContext.getHeaders().entrySet()) {
            for (final Object value : e.getValue()) {
                response.putHeader(e.getKey(), String.valueOf(value));
            }
        }

        // Run any response processors
        for (VertxResponseProcessor processor : responseProcessors) {
View Full Code Here

     */
    @Override
    public void failure(Throwable error) {

        container.logger().error(error.getMessage(), error);
        HttpServerResponse response = vertxRequest.response();

        // Set error status and end
        Response.Status status = Response.Status.INTERNAL_SERVER_ERROR;
        response.setStatusCode(status.getStatusCode());
        response.setStatusMessage(status.getReasonPhrase());
        response.end();

    }
View Full Code Here

TOP

Related Classes of org.vertx.java.core.http.HttpServerResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.