Package com.volantis.shared.net.http

Examples of com.volantis.shared.net.http.HTTPMessageEntities


     *
     * It is assumed, that this method is called after setting authentication
     * token on contextAuthData
     */
    private void setAuthenticationTokenHeader() {
        HTTPMessageEntities entities = (HTTPMessageEntities)
                context.getProperty(WebRequestHeader.class);
        if (entities == null) {
            entities = new SimpleHTTPMessageEntities();
        }
        WebRequestHeader header = new WebRequestHeader();
        header.setName(GOOGLE_AUTH_HEADER_KEY);
        header.setValue(MessageFormat.format(GOOGLE_AUTH_HEADER_VALUE, authData.getAuthToken()));
        entities.remove(header.getIdentity());
        entities.add(header);

        context.setProperty(WebRequestHeader.class, entities, false);
    }
View Full Code Here


         * Copies cookies from the HTTPResponseAccessor.
         *
         * @throws HTTPException
         */
        private void storeCookies() throws HTTPException {
            final HTTPMessageEntities cookieEntities = accessor.getCookies();
            if (cookieEntities != null) {
                cookies = new LinkedList();
                for (Iterator iter = cookieEntities.iterator(); iter.hasNext(); ) {
                    final Cookie cookie = (Cookie) iter.next();
                    final com.volantis.shared.net.url.http.Cookie dstCookie =
                        new com.volantis.shared.net.url.http.Cookie() {
                            public boolean isSecure() {
                                return cookie.isSecure();
View Full Code Here

         * Copies headers from the HTTPResponseAccessor.
         *
         * @throws HTTPException
         */
        private void storeHeaders() throws HTTPException {
            final HTTPMessageEntities headerEntities = accessor.getHeaders();
            if (headerEntities != null) {
                headers = new LinkedList();
                for (Iterator iter = headerEntities.iterator(); iter.hasNext(); ) {
                    final Header header = (Header) iter.next();
                    final com.volantis.shared.net.url.http.Header dstCookie =
                        new com.volantis.shared.net.url.http.Header() {
                            public String getName() {
                                return header.getName();
View Full Code Here

     */
    public static HTTPMessageEntities retrieveRequestHeaders(
            final WebDriverRequest request,
            XMLPipelineContext xmlPipelineContext) throws HTTPException {
        // will store any headers
        final HTTPMessageEntities headers =
                HTTPFactory.getDefaultInstance()
                .createHTTPMessageEntities();
        // create an entity adder that adds request headers to the executor
        DerivableHTTPMessageEntityAdder headerAdder =
                new DerivableHTTPMessageEntityAdder() {
                    // javadoc inherited
                    public void addDerivableHTTPMessageEntity(
                            DerivableHTTPMessageEntity header)
                            throws HTTPException {
                        // obtain the outgoing headers
                        Header[] headerArray = acquireOutgoingHeaders(header,
                                                                      request);
                        for (int i = 0; i < headerArray.length; i++) {
                            headers.add(headerArray[i]);
                        }

                    }
                };
        // add the headers
        addHTTPMessageEntities(WebRequestHeader.class, headerAdder,
                               xmlPipelineContext);

        if (headers.size() == 0 && request != null &&
                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

     */
    protected static Header[] acquireOutgoingHeaders(
            DerivableHTTPMessageEntity header,
            WebDriverRequest request) throws HTTPException {

        HTTPMessageEntities headers = null;
        if (request != null) {
            headers = request.getHeaders();
        }
        final Header[] values = (Header[]) aquireOutgoingHTTPMessageEntitys(
            header, headers, HEADER_MERGER);
View Full Code Here

     */
    public static HTTPMessageEntities retrieveRequestCookies(
            final WebDriverRequest request,
            XMLPipelineContext xmlPipelineContext) throws HTTPException {
        // will store any cookies
        final HTTPMessageEntities cookies =
                HTTPFactory.getDefaultInstance()
                .createHTTPMessageEntities();

        DerivableHTTPMessageEntityAdder cookieAdder =
                new DerivableHTTPMessageEntityAdder() {
                    // javadoc inherited
                    public void addDerivableHTTPMessageEntity(
                            DerivableHTTPMessageEntity cookie)
                            throws HTTPException {
                        Cookie[] cookieArray = acquireOutgoingCookies(cookie,
                                                                      request);
                        for (int i = 0; i < cookieArray.length; i++) {
                            cookies.add(cookieArray[i]);
                        }
                    }
                };
        // add all the cookies from the request
        addHTTPMessageEntities(WebRequestCookie.class, cookieAdder,
                               xmlPipelineContext);

        if (cookies != null) {
            if (cookies.size() == 0 && request != null &&
                    request.getCookies() != null) {

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

                    Cookie cookie = (Cookie) i.next();
                    cookies.add(cookie);
                }
            }
        }
        // return the cookies
        return cookies;
View Full Code Here

     */
    public static HTTPMessageEntities retrieveRequestParameters(
            final WebDriverRequest request,
            XMLPipelineContext xmlPipelineContext) throws HTTPException {
        // will store any parameters
        final HTTPMessageEntities parameters =
                HTTPFactory.getDefaultInstance().createHTTPMessageEntities();

        DerivableHTTPMessageEntityAdder parameterAdder =
                new DerivableHTTPMessageEntityAdder() {
                    // javadoc inherited
                    public void addDerivableHTTPMessageEntity(
                            DerivableHTTPMessageEntity parameter)
                            throws HTTPException {
                        RequestParameter[] paramaterArray =
                                acquireOutgoingParameters(parameter,
                                                          request);
                        for (int i = 0; i < paramaterArray.length; i++) {
                            parameters.add(paramaterArray[i]);
                        }
                    }
                };
        // add the parameters
        addHTTPMessageEntities(WebRequestParameter.class, parameterAdder,
                               xmlPipelineContext);

        if (parameters != null) {
            if (parameters.size() == 0 && request != null &&
                    request.getRequestParameters() != null) {

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

                    RequestParameter parameter = (RequestParameter)i.next();
                    parameters.add(parameter);
                }
            }
        }
        // return the parameters
        return parameters;
View Full Code Here

     */
    protected static void addHTTPMessageEntities(Class entityType,
                                                 DerivableHTTPMessageEntityAdder adder,
                                                 XMLPipelineContext xmlPipelineContext)
            throws HTTPException {
        HTTPMessageEntities entities =
                (HTTPMessageEntities) xmlPipelineContext.getProperty(
                        entityType);

        if (entities != null && entities.size() > 0) {
            // If there are any headers defined as properties in the context
            // then merge them with the headers defined in the WebDriverRequest.
            Iterator iterator = entities.iterator();
            while (iterator.hasNext()) {
                DerivableHTTPMessageEntity entity =
                        (DerivableHTTPMessageEntity) iterator.next();
                adder.addDerivableHTTPMessageEntity(entity);
            }
View Full Code Here

     */
    protected static RequestParameter[] acquireOutgoingParameters(
            DerivableHTTPMessageEntity param,
            WebDriverRequest request) throws HTTPException {

        HTTPMessageEntities params = null;
        if (request != null) {
            params = request.getRequestParameters();
        }
        final RequestParameter[] values = (RequestParameter[])
                aquireOutgoingHTTPMessageEntitys(param,
View Full Code Here

     */
    protected static Cookie[] acquireOutgoingCookies(
            DerivableHTTPMessageEntity cookie,
            WebDriverRequest request) throws HTTPException {

        HTTPMessageEntities cookies = null;
        if (request != null) {
            cookies = request.getCookies();
        }

        final Cookie[] values = (Cookie[]) aquireOutgoingHTTPMessageEntitys(
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.http.HTTPMessageEntities

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.