Package com.volantis.shared.net.http.headers

Examples of com.volantis.shared.net.http.headers.Header


        entities.add(header2);
        header2.setValue("value2");
        entities.add(header3);
        entities.add(header4);

        Header headers [] = new Header[3];
        headers[0] = new HeaderImpl(name1);
        headers[1] = new HeaderImpl(name1);
        headers[2] = new HeaderImpl(name2);

        // Putting the headers array should replace header1, header2 and
View Full Code Here


        cookieHeader.setValue(cookieValue);
        cookieHeader.setVersion(cookieVersion);

        String headerName = "Other-Header";
        String headerValue = "o-h-value";
        final Header otherHeader = new HeaderImpl(headerName);
        otherHeader.setValue(headerValue);

        String method = "populateWebDriverResponse";
        Class paramTypes [] = {
            WebDriverResponse.class,
            HTTPResponseAccessor.class,
View Full Code Here

        final Cookie cookie1 = new CookieImpl(cookieName, "localhost", "/");
        cookie1.setValue(cookieValue);

        String headerName = "Other-Header";
        String headerValue = "o-h-value";
        final Header otherHeader = new HeaderImpl(headerName);
        otherHeader.setValue(headerValue);

        HTTPMessageEntities additionalCookies = new SimpleHTTPMessageEntities();
        Cookie additionalCookie = new CookieImpl("additionalName",
                                                 "localhost",
                                                 "/");
View Full Code Here

            WebDriverRequest request = accessor.getRequest(context);

            HTTPMessageEntities headers =
                    HTTPFactory.getDefaultInstance().
                    createHTTPMessageEntities();
            Header header1 = new HeaderImpl("name");
            header1.setValue("fred");
            Header header2 = new HeaderImpl("request2");
            header2.setValue("jane");
            headers.add(header1);
            headers.add(header2);
            request.setHeaders(headers);

            context.setProperty(WebDriverAccessor.class, accessor, false);
View Full Code Here

                    public void preprocessResponse(HTTPMessageEntities headers,
                                                       HTTPMessageEntities cookies,
                            int statusCode) {
                            // create a content type header in order to perform a
                            // lookup
                            Header contentType =
                                    HTTPFactory.getDefaultInstance()
                                    .createHeader("Content-Type");

                            // retrieve all the contentType headers
                        Header[] headerArray = (Header[]) headers.retrieve(contentType.getIdentity());

                            // change all contentType headers
                            for (int i = 0; i < headerArray.length; i++) {
                                contentType = headerArray[i];
                                contentType.setValue("text/xml");
                            }
                        }
                    }, false);
            WebDriverAccessor accessor = createWebDriverAccessor();
            context.setProperty(WebDriverAccessor.class, accessor, false);
View Full Code Here

            WebDriverResponse response,
                                    String expectedName,
                                    String expectedValue) {

        HTTPMessageEntities headers = response.getHeaders();
        Header expected =
                HTTPFactory.getDefaultInstance().createHeader(expectedName);

        Header[] headerArray = (Header[]) headers.retrieve(
                expected.getIdentity());

        assertNotNull("Should be a " + expectedName + " header", headerArray);
        assertEquals("Should only be a single " + expectedName + " header",
                     1,
                     headerArray.length);
View Full Code Here

                                      List expectedValues) {

        HTTPMessageEntities headers = response.getHeaders();
        int expectedCount = expectedValues.size();

        Header expected = HTTPFactory.getDefaultInstance().createHeader(
                expectedName);
        Header[] headerArray = (Header[]) headers.retrieve(
                expected.getIdentity());

        assertNotNull("Should be " + expectedName + " headers", headerArray);
        assertEquals("Should only be " + expectedCount + " " + expectedName +
                     " headers",
                     expectedCount,
View Full Code Here

                request.getHeaders() != null) {

            for(Iterator i = request.getHeaders().iterator();
                i.hasNext(); ) {

                Header header = (Header) i.next();
                headers.add(header);
            }
        }

        // add visited MCS instances header
        final String instances = (String) xmlPipelineContext.getProperty(
            URLConfigurationFactory.VISITED_MCS_INSTANCES_HEADER_NAME);
        if (instances != null) {
            final Header header = HTTPFactory.getDefaultInstance().createHeader(
                URLConfigurationFactory.VISITED_MCS_INSTANCES_HEADER_NAME);
            header.setValue(instances);
            headers.put(header);
        }

        // return the headers
        return headers;
View Full Code Here

             */
            private void transferRequestHeaders(HttpMethod method,
                                                List requestHeaders) {
                if (requestHeaders != null) {
                    for (int i = 0; i < requestHeaders.size(); i++) {
                        Header header = (Header) requestHeaders.get(i);
                        String name = header.getName();
                        if (!HEADERS_EXCLUDED_FROM_TRANSFER.contains(name)) {
                            method.addRequestHeader(name, header.getValue());
                        }
                    }
                }
            }
        };
View Full Code Here

        HTTPFactory factory = HTTPFactory.getDefaultInstance();
        final String headerName = httpClientHeader.getName();
        final List values = HttpClientUtils.getHeaderValueList(httpClientHeader);
        if (values.size() == 0) {
            Header header = factory.createHeader(headerName);
            headers.add(header);
        } else {
            if (valueList) {
                for (Iterator iter = values.iterator(); iter.hasNext(); ) {
                    final Header header = factory.createHeader(headerName);
                    final String value = (String) iter.next();
                    header.setValue(value);
                    headers.add(header);
                }
            } else {
                StringBuffer reconstitutedHeader = new StringBuffer();
                Iterator it = values.iterator();
                while (it.hasNext()) {
                    if (reconstitutedHeader.length() > 0) {
                        reconstitutedHeader.append(',');
                    }
                    reconstitutedHeader.append(it.next());
                }
                final Header header = factory.createHeader(headerName);
                header.setValue(reconstitutedHeader.toString());
                headers.add(header);
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.http.headers.Header

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.