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

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


            HttpServletRequest httpRequest,
            MarinerRequestContext marinerRequestContext,
            String remoteProjectName,
            GenericURLRemapper urlRemapper) {

        WebDriverRequest request = new WebDriverRequestImpl();

        final HTTPFactory httpFactory = HTTPFactory.getDefaultInstance();

        HTTPMessageEntities headers = httpFactory.createHTTPMessageEntities();
        Enumeration headerNames = httpRequest.getHeaderNames();
        while (headerNames.hasMoreElements()) {
            final String name = (String) headerNames.nextElement();
            final Header header = httpFactory.createHeader(name);
            header.setValue(httpRequest.getHeader(name));
            headers.add(header);
        }

        HTTPMessageEntities parameters = httpFactory.createHTTPMessageEntities();
        // get parameters from marinerRequestContext if available
        // ported from 4.2.0, see vbm 2007070313
        Enumeration parameterNames = (marinerRequestContext != null) ?
            marinerRequestContext.getParameterNames() :
            httpRequest.getParameterNames();
        while (parameterNames.hasMoreElements()) {
            final String name = (String) parameterNames.nextElement();
            final RequestParameter parameter =
                    httpFactory.createRequestParameter(name);
            final String value = (marinerRequestContext != null) ?
                    marinerRequestContext.getParameter(name) :
                    httpRequest.getParameter(name);  
            parameter.setValue(value);
            parameters.add(parameter);
        }

        // HTTP-Client will only send cookies if a domain and path is supplied.
        // Unfortunately when using Netscape cookies, (Version 0), domain
        // and path information is not sent in the COOKIE header, hence when
        // Netscape cookies are used we do not have values for the domain
        // and path.
        URL remoteMCSProjectLocation =
                urlRemapper.getRemoteSiteRootURL(remoteProjectName);

        // However, the fact that non JSESSIONID cookies have been sent to
        // MCS indicates that they should be sent to the target server.  So
        // we can just set the domain equal to the remote target host
        // and the path to "/".
        final String defaultDomain = remoteMCSProjectLocation.getHost();
        final String defaultPath = "/";

        HTTPMessageEntities cookies = httpFactory.createHTTPMessageEntities();
        javax.servlet.http.Cookie[] httpCookies = httpRequest.getCookies();

        if (httpCookies != null) {
            for (int i = 0; i < httpCookies.length; i++) {
                javax.servlet.http.Cookie httpCookie = httpCookies[i];
                final Cookie cookie = httpFactory.createCookie(httpCookie.getName(),
                        defaultDomain, defaultPath);
                cookie.setMaxAge(httpCookie.getMaxAge());
                cookie.setSecure(httpCookie.getSecure());

                cookie.setValue(httpCookie.getValue());
                cookie.setVersion(CookieVersion.getCookieVersion(httpCookie.getVersion()));
                cookies.add(cookie);
            }
        }

        request.setHeaders(headers);
        request.setRequestParameters(parameters);
        request.setCookies(cookies);

        return request;
    }
View Full Code Here

TOP

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

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.