Package play.mvc.Http

Examples of play.mvc.Http.Response


    // Tests to check whether input streams to renderBinary are closed.

    @Test
    public void testGetEmptyBinary() {
        Response response = GET("/binary/getEmptyBinary");
        assertIsOk(response);
        assertTrue(Binary.emptyInputStreamClosed);
    }
View Full Code Here


        assertTrue(Binary.emptyInputStreamClosed);
    }

    @Test
    public void testGetErrorBinary() {
        Response response = GET("/binary/getErrorBinary");
        // This does not work. See Lighthouse ticket #1637.
        // assertStatus(500, response);
        assertTrue(Binary.errorInputStreamClosed);
    }
View Full Code Here

        if ( closestLocale == null ) {
            // Give up
            return ;
        }
        if ( set(closestLocale) ) {
            Response response = Response.current();
            if ( response != null ) {
                // We have a current response in scope - set the language-cookie to store the selected language for the next requests
                response.setCookie(Play.configuration.getProperty("application.lang.cookie", "PLAY_LANG"), locale, null, "/", null, Scope.COOKIE_SECURE);
            }
        }

    }
View Full Code Here

            // Plain old HttpRequest
            try {
                final Request request = parseRequest(ctx, nettyRequest, messageEvent);

                final Response response = new Response();
                Http.Response.current.set(response);

                // Buffered in memory output
                response.out = new ByteArrayOutputStream();

                // Direct output (will be set later)
                response.direct = null;

                // Streamed output (using response.writeChunk)
                response.onWriteChunk(new Action<Object>() {

                    public void invoke(Object result) {
                        writeChunk(request, response, ctx, nettyRequest, result);
                    }
                });
View Full Code Here

        if (exposePlayServer) {
            nettyResponse.setHeader(SERVER, signature);
        }

        Request request = Request.current();
        Response response = Response.current();

        String encoding = response.encoding;

        try {
            if (!(e instanceof PlayException)) {
View Full Code Here

                request.body = new ByteArrayInputStream(new byte[0]);
                Request.current.set(request);
            }

            if (Response.current() == null) {
                Response response = new Response();
                response.out = new ByteArrayOutputStream();
                response.direct = null;
                Response.current.set(response);
            }
View Full Code Here

            Logger.trace("ServletWrapper>service " + httpServletRequest.getRequestURI());
        }

        Request request = null;
        try {
            Response response = new Response();
            response.out = new ByteArrayOutputStream();
            Response.current.set(response);
            request = parseRequest(httpServletRequest);

            if (Logger.isTraceEnabled()) {
View Full Code Here

     * @param url relative url such as <em>"/products/1234"</em>
     * @param followRedirect indicates if request have to follow redirection (status 302)
     * @return the response
     */
    public static Response GET(Object url, boolean followRedirect) {
        Response response = GET(url);
        if (Http.StatusCode.FOUND == response.status && followRedirect) {
            Http.Header redirectedTo = response.headers.get("Location");
            String location = redirectedTo.value();
            if(location.contains("http")){
              java.net.URL redirectedUrl = null;
View Full Code Here

            throw new RuntimeException(ex);
        }
    }

    public static Response makeRequest(final Request request) {
        Response response = newResponse();
        makeRequest(request, response);

        if (response.status == 302) { // redirect
            // if Location-header is pressent, fix it to "look like" a functional-test-url
            Http.Header locationHeader = response.headers.get("Location");
View Full Code Here

        }
        return response;
    }

    public static Response newResponse() {
        Response response = new Response();
        response.out = new ByteArrayOutputStream();
        return response;
    }
View Full Code Here

TOP

Related Classes of play.mvc.Http.Response

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.