Package com.sun.grizzly.util.buf

Examples of com.sun.grizzly.util.buf.MessageBytes


        if (proxyName != null) {
            req.serverName().setString(proxyName);
        }

        // URI decoding
        MessageBytes decodedURI = req.decodedURI();
        if (compatWithTomcat || !v3Enabled) {          
            decodedURI.duplicate(req.requestURI());
            try {
              req.getURLDecoder().convert(decodedURI, false);
            } catch (IOException ioe) {
              res.setStatus(400);
              res.setMessage("Invalid URI: " + ioe.getMessage());
              return false;
            }

            /* GlassFish Issue 2339
            // Normalize decoded URI
            if (!normalize(req.decodedURI())) {
                res.setStatus(400);
                res.setMessage("Invalid URI");
                return false;
            }
            */

            // Set the remote principal
            String principal = req.getRemoteUser().toString();
            if (principal != null) {
                request.setUserPrincipal(new CoyotePrincipal(principal));
            }

            // Set the authorization type
            String authtype = req.getAuthType().toString();
            if (authtype != null) {
                request.setAuthType(authtype);
            }

            /* CR 6309511
            // URI character decoding
            convertURI(decodedURI, request);

            // Parse session Id
            parseSessionId(req, request);
             */
            // START CR 6309511
            // URI character decoding
            request.convertURI(decodedURI);

            // START GlassFish Issue 2339
            // Normalize decoded URI
            if (!normalize(decodedURI)) {
                res.setStatus(400);
                res.setMessage("Invalid URI");
                return false;
            }
            // END GlassFish Issue 2339
        }
        // END CR 6309511

        /*
         * Remove any parameters from the URI, so they won't be considered
         * by the mapping algorithm, and save them in a temporary CharChunk,
         * so that any session id param may be parsed once the target
         * context, which may use a custom session parameter name, has been
         * identified
         */
        CharChunk uriParamsCC = request.getURIParams();
        CharChunk uriCC = decodedURI.getCharChunk();
        int semicolon = uriCC.indexOf(';');
        if (semicolon > 0) {
            uriParamsCC.setChars(uriCC.getBuffer(), semicolon,
                uriCC.getEnd() - semicolon);
            decodedURI.setChars(uriCC.getBuffer(), uriCC.getStart(),
                semicolon);
        }
        if (compatWithTomcat || !v3Enabled) {
            /*mod_jk*/
            MessageBytes localDecodedURI = decodedURI;
            if (semicolon > 0) {
                localDecodedURI = (MessageBytes)req.getNote(MESSAGE_BYTES);
                if (localDecodedURI == null) {
                    localDecodedURI = MessageBytes.newInstance();
                    req.setNote(MESSAGE_BYTES, localDecodedURI);
                }
                localDecodedURI.duplicate(decodedURI);
            }
            connector.getMapper().map(req.serverName(), localDecodedURI,
                                  request.getMappingData());
            MappingData md = request.getMappingData();
            req.setNote(MAPPING_DATA, md);
            request.updatePaths(md);
        }

        Context ctx = (Context) request.getMappingData().context;

        // Parse session id
        if (ctx != null && !uriParamsCC.isNull()) {
            request.parseSessionId(ctx.getSessionParameterName(), uriParamsCC);
        }

        // START GlassFish 1024
        request.setDefaultContext(request.getMappingData().isDefaultContext);
        // END GlassFish 1024

        // START SJSAS 6253524
        // request.setContext((Context) request.getMappingData().context);
        // END SJSAS 6253524
        // START SJSAS 6253524
        request.setContext(ctx);
        // END SJSAS 6253524

        if (ctx != null && !uriParamsCC.isNull()) {
            request.parseSessionVersion(uriParamsCC);
        }

        if (!uriParamsCC.isNull()) {
            request.parseJReplica(uriParamsCC);
        }

        request.setWrapper((Wrapper) request.getMappingData().wrapper);

        // Filter trace method
        if (!connector.getAllowTrace()
                && req.method().equalsIgnoreCase("TRACE")) {
            Wrapper wrapper = request.getWrapper();
            String header = null;
            if (wrapper != null) {
                String[] methods = wrapper.getServletMethods();
                if (methods != null) {
                    for (int i=0; i<methods.length; i++) {
                        // Exclude TRACE from methods returned in Allow header
                        if ("TRACE".equals(methods[i])) {
                            continue;
                        }
                        if (header == null) {
                            header = methods[i];
                        } else {
                            header += ", " + methods[i];
                        }
                    }
                }
            }                              
            res.setStatus(405);
            res.addHeader("Allow", header);
            res.setMessage("TRACE method is not allowed");
            return false;
        }

        // Possible redirect
        MessageBytes redirectPathMB = request.getMappingData().redirectPath;
        // START SJSAS 6253524
        // if (!redirectPathMB.isNull()) {
        // END SJSAS 6253524
        // START SJSAS 6253524
        if (!redirectPathMB.isNull()
            && (!ctx.hasAdHocPaths()
                || (ctx.getAdHocServletName(((HttpServletRequest)
                        request.getRequest()).getServletPath()) == null))) {
        // END SJSAS 6253524
            String redirectPath = redirectPathMB.toString();
            String query = request.getQueryString();
            if (request.isRequestedSessionIdFromURL()) {
                // This is not optimal, but as this is not very common, it
                // shouldn't matter
                redirectPath = redirectPath + ";" + ctx.getSessionParameterName() + "="
View Full Code Here


            }

            // at this point the post construct should have been called.
            // seems like there is some possibility that the container is not synchronously started
            // preventing the calls below to succeed...
            MessageBytes decodedURI = req.decodedURI();
            try {
                // Clear the previous mapped information.
                MappingData mappingData =
                        (MappingData) req.getNote(ContainerMapper.MAPPING_DATA);
                mappingData.recycle();
View Full Code Here

                    a.service(req, res);
                    return;
                }
            }

            MessageBytes decodedURI = req.decodedURI();
            decodedURI.duplicate(req.requestURI());
            mappingData = (MappingData) req.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                req.setNote(MAPPING_DATA, mappingData);
            }
            Adapter adapter = null;
           
            String uriEncoding = (String) grizzlyEmbeddedHttp.getProperty("uriEncoding");
            HttpRequestURIDecoder.decode(decodedURI, urlDecoder, uriEncoding, null);

            final CharChunk decodedURICC = decodedURI.getCharChunk();
            final int semicolon = decodedURICC.indexOf(';', 0);

            // Map the request without any trailling.
            adapter = mapUriWithSemicolon(req, decodedURI, semicolon, mappingData);
            if (adapter == null || adapter instanceof ContainerMapper) {
                String ext = decodedURI.toString();
                String type = "";
                if (ext.indexOf(".") > 0) {
                    ext = "*" + ext.substring(ext.lastIndexOf("."));
                    type = ext.substring(ext.lastIndexOf(".") + 1);
                }

                if (!MimeType.contains(type) && !ext.equals("/")){
                    initializeFileURLPattern(ext);
                    mappingData.recycle();
                    adapter = mapUriWithSemicolon(req, decodedURI, semicolon, mappingData);
                } else {
                    super.service(req, res);
                    return;
                }
            }

            if (logger.isLoggable(Level.FINE)) {
                logger.log(Level.FINE, "Request: {0} was mapped to Adapter: {1}",
                        new Object[]{decodedURI.toString(), adapter});
            }

            // The Adapter used for servicing static pages doesn't decode the
            // request by default, hence do not pass the undecoded request.
            if (adapter == null || adapter instanceof ContainerMapper) {
View Full Code Here

        if (semicolonPos == 0) {
            semicolonPos = decodedURI.indexOf(';');
        }

        MessageBytes localDecodedURI = decodedURI;
        if (semicolonPos >= 0) {
            charChunk.setEnd(semicolonPos);
            // duplicate the URI path, because Mapper may corrupt the attributes,
            // which follow the path
            localDecodedURI = (MessageBytes) req.getNote(MESSAGE_BYTES);
            if (localDecodedURI == null) {
                localDecodedURI = MessageBytes.newInstance();
                req.setNote(MESSAGE_BYTES, localDecodedURI);
            }
            localDecodedURI.duplicate(decodedURI);
        }


        try {
            return map(req, localDecodedURI, mappingData);
View Full Code Here

TOP

Related Classes of com.sun.grizzly.util.buf.MessageBytes

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.