Package org.eclipse.jetty.client.api

Examples of org.eclipse.jetty.client.api.Request.header()


               
                //do another request to access the session, this will cause session to be initially
                //checked against db. On exit of request, the access time will need updating, so the
                //session will be saved to db.
                request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
                request.header("Cookie", sessionCookie);
                response = request.send();
                assertEquals(HttpServletResponse.SC_OK,response.getStatus());
                tmp = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
                assertNotEquals(lastSaved, tmp);
                lastSaved = tmp;
View Full Code Here


               
                //do another request to access the session. This time, the save interval has not
                //expired, so we should NOT see a debug trace of loading stale session. Nor should
                //the exit of the request cause a save of the updated access time.
                request = client.newRequest("http://localhost:" + port + "/mod/test?action=tickle");
                request.header("Cookie", sessionCookie);
                response = request.send();
                assertEquals(HttpServletResponse.SC_OK,response.getStatus());
                tmp = ((JDBCSessionManager.Session)servlet._session).getLastSaved();
                assertEquals(lastSaved, tmp); //the save interval did not expire, so update to the access time will not have been persisted
            }
View Full Code Here

        int port=server.getPort();

        //Log.getLog().setDebugEnabled(true);
        Request request = client.newRequest("http://localhost:" + port + "" + "/test");
        if (sessionCookie != null)
            request.header("Cookie", sessionCookie);
        ContentResponse response = request.send();
        assertEquals(HttpServletResponse.SC_OK, response.getStatus());

        sessionCookie = response.getHeaders().get("Set-Cookie");
        assertTrue( sessionCookie != null );
View Full Code Here

               
                //restart webapp
                webApp.start();
               
                Request request = client.newRequest("http://localhost:" + port1 + contextPath + "/bar?action=get");
                request.header("Cookie", sessionCookie);
                response = request.send();
                assertEquals(HttpServletResponse.SC_OK,response.getStatus());
                String afterStopSessionId = (String)webApp.getServletContext().getAttribute("foo.session");
               
                assertNotNull(afterStopSessionId);
View Full Code Here

        Map<String, Collection<String>> headers = request.getHeaders();
        for (Map.Entry<String, Collection<String>> stringCollectionEntry : headers.entrySet()) {
            String key = stringCollectionEntry.getKey();
            Collection<String> stringCollection = stringCollectionEntry.getValue();
            String value = joiner.join(stringCollection);
            httpRequest = httpRequest.header(key, value);
        }

        for (Map.Entry<String, Collection<String>> stringCollectionEntry : request.getQueryParams().entrySet()) {
            String key = stringCollectionEntry.getKey();
            Collection<String> stringCollection = stringCollectionEntry.getValue();
View Full Code Here

                url += type;
            }
        }

        final Request request = _httpClient.newRequest(url).method(HttpMethod.POST);
        request.header(HttpHeader.CONTENT_TYPE.asString(), "application/json;charset=UTF-8");

        StringBuilder builder = new StringBuilder();
        for (HttpCookie cookie : getCookieStore().get(uri))
        {
            builder.setLength(0);
View Full Code Here

        StringBuilder builder = new StringBuilder();
        for (HttpCookie cookie : getCookieStore().get(uri))
        {
            builder.setLength(0);
            builder.append(cookie.getName()).append("=").append(cookie.getValue());
            request.header(HttpHeader.COOKIE.asString(), builder.toString());
        }

        request.content(new StringContentProvider(generateJSON(messages)));

        customize(request);
View Full Code Here

        publish.onResponseBegin(new Response.BeginListener()
        {
            @Override
            public void onBegin(Response response)
            {
                publish.header(HttpHeader.CONTENT_TYPE, null);
            }
        });
        response = publish.send();
        Assert.assertEquals(200, response.getStatus());
View Full Code Here

                "\"channel\": \"/meta/handshake\"," +
                "\"version\": \"1.0\"," +
                "\"minimumVersion\": \"1.0\"," +
                "\"supportedConnectionTypes\": [\"long-polling\"]" +
                "}]");
        handshake.header(name, value1);
        handshake.header(name, value2);
        ContentResponse response = handshake.send();
        Assert.assertEquals(200, response.getStatus());

        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
View Full Code Here

                "\"version\": \"1.0\"," +
                "\"minimumVersion\": \"1.0\"," +
                "\"supportedConnectionTypes\": [\"long-polling\"]" +
                "}]");
        handshake.header(name, value1);
        handshake.header(name, value2);
        ContentResponse response = handshake.send();
        Assert.assertEquals(200, response.getStatus());

        Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.