Package com.volantis.xml.pipeline.sax.drivers.web

Examples of com.volantis.xml.pipeline.sax.drivers.web.HTTPResponseAccessor


            "</HEAD>",
            "<BODY>",
            "<H1>Fake response</H1>"
        };
        AbstractPluggableHTTPManager manager = createTestInstance();
        HTTPResponseAccessor resp =
                performRequest(manager, fakeResponse,
                                HTTPRequestType.GET, "?wibble=wobble");

        HTTPResponseAccessor resp2 =
                performRequest(manager, fakeResponse,
                                HTTPRequestType.GET, "?wibble=wont");

        assertTrue("The content should be the same",
            equals(resp.getResponseStream(), resp2.getResponseStream()));
        assertFalse("The server used up all of the transactions.",
            serverMock.hasTransactions());
    }
View Full Code Here


            "</HEAD>",
            "<BODY>",
            "<H1>Fake response</H1>"
        };
        AbstractPluggableHTTPManager manager = createTestInstance();
        HTTPResponseAccessor resp =
                performRequest(manager, fakeResponse,
                                HTTPRequestType.GET, "?wibble=wobble");

        HTTPResponseAccessor resp2 =
                performRequest(manager, fakeResponse,
                                HTTPRequestType.GET, "?wibble=wont");

        assertTrue("The content should be the same",
            equals(resp.getResponseStream(), resp2.getResponseStream()));
        assertFalse("The server used up all of the transactions.",
            serverMock.hasTransactions());
    }
View Full Code Here

            "Date: " + getStringDate(new Date(System.currentTimeMillis() + 1000)),
            "Content-Type: text/html",
            ""
        };
        AbstractPluggableHTTPManager manager = createTestInstance();
        HTTPResponseAccessor resp =
                performRequest(manager, fakeResponse,
                                HTTPRequestType.POST, null);
        assertEquals("response should be a 400", 400, resp.getStatusCode());

    }
View Full Code Here

                                   final Object key,
                                   final CacheEntry entry) {

        HttpContent httpContent;
        CachedHttpContentState state = null;
        HTTPResponseAccessor accessor;
        boolean cacheable = false;
        ProviderResult result = null;
        try {
            // check if validation headers can be added
            if (entry != null) {
                final CachedHttpContentState existingState =
                    (CachedHttpContentState) entry.getExtensionObject();
                if (existingState != null) {
                    // this is a validation
                    // set the If-Modified-Since header using the stored
                    // last modified value (if there is any)
                    final Time lastModified = existingState.getLastModified();
                    if (lastModified != null) {
                        final String lastModifiedAsString;
                        // SimpleDateFormat is not thread safe
                        synchronized (RFC1123) {
                            lastModifiedAsString = RFC1123.format(
                                new Date(lastModified.inMillis()));
                        }
                        final Header header =
                            new HeaderImpl(HeaderNames.IF_MODIFIED_SINCE_HEADER);
                        header.setValue(lastModifiedAsString);
                        executor.addRequestHeader(header);
                    }

                    // set the If-None-Match header with the eTag value, if
                    // there is any
                    final String eTag = existingState.getETag();
                    if (eTag != null && eTag.trim().length() > 0) {
                        final Header header =
                            new HeaderImpl(HeaderNames.IF_NONE_MATCH_HEADER);
                        header.setValue(eTag);
                        executor.addRequestHeader(header);
                    }
                }
            }

            // record the request time
            final CachedHttpContentStateBuilder builder =
                new CachedHttpContentStateBuilder();
            builder.setRequestTime(clock.getCurrentTime());
            accessor = executor.execute();
            // record response time
            builder.setResponseTime(clock.getCurrentTime());

            // process the response
            builder.setMethodAccessor(
                new HttpResponseHeaderAccessorWrapper(accessor));
            httpContent = new HTTPResponseAccessorWrapper(accessor);
            final int statusCode = accessor.getStatusCode();
            if (isStatusCodeCachable(statusCode)) {
                state = builder.build();
                if (state != null && state.isCacheable()) {
                    httpContent = new CachedHttpContent(httpContent, state, clock,
                        new CacheableDependency(key, state, clock,
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.drivers.web.HTTPResponseAccessor

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.