Package org.glassfish.grizzly.http.util

Examples of org.glassfish.grizzly.http.util.DataChunk


   
    @Override
    public void service(final Request request, final Response response)
            throws Exception {
        // don't decode and avoid creating a string
        final DataChunk requestURIBC = request.getRequest()
                .getRequestURIRef().getRequestURIBC();
       
        if (requestURIBC.equals("/json")) {
            jsonHandler.service(request, response);
        } else {
            plainTextHandler.service(request, response);
        }
    }
View Full Code Here


                    httpHandler.service(request, response);
                    return;
                }
            }

            final DataChunk decodedURI = request.getRequest()
                    .getRequestURIRef().getDecodedRequestURIBC(isAllowEncodedSlash());

            mappingData = request.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                request.setNote(MAPPING_DATA, mappingData);
            } else {
                mappingData.recycle();
            }
            HttpHandler httpService;

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

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

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

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

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

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

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


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

                    return new HttpHandlerCallable(httpHandler,
                            request, response);
                }
            }

            final DataChunk decodedURI = request.getRequest()
                    .getRequestURIRef().getDecodedRequestURIBC(isAllowEncodedSlash());

            mappingData = request.getNote(MAPPING_DATA);
            if (mappingData == null) {
                mappingData = new MappingData();
                request.setNote(MAPPING_DATA, mappingData);
            } else {
                mappingData.recycle();
            }
            HttpHandler httpHandler;

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

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

                if (!MimeType.contains(type) && !"/".equals(ext)) {
                    initializeFileURLPattern(ext);
                    mappingData.recycle();
                    httpHandler = mapUriWithSemicolon(request, decodedURI,
                            semicolon, mappingData);
                } else {
//                    super.service(request, response);
//                    return;
                    return new SuperCallable(request, response);
                }
            }

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

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

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

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


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

     */
    private void removeParameterFromRequestURI(String parameter) {

        int semicolon, semicolon2;

        final DataChunk uriBC =
                coyoteRequest.getRequest().getRequestURIRef().getRequestURIBC();
       
//        start = uriBC.getStart();
//        end = uriBC.getEnd();
        semicolon = uriBC.indexOf(parameter, 0);

        if (semicolon > 0) {
            semicolon2 = uriBC.indexOf(';', semicolon + parameter.length());

            final int end;
            if (semicolon2 >= 0) {
                end = semicolon2;
                uriBC.notifyDirectUpdate();
            } else {
                end = uriBC.getLength();
            }
           
            uriBC.delete(semicolon, end);
//            uriBC.setEnd(start + semicolon);
//            byte[] buf = uriBC.getBuffer();
//            if (semicolon2 >= 0) {
//                for (int i = 0; i < end - start - semicolon2; i++) {
//                    buf[start + semicolon + i] = buf[start + i + semicolon2];
View Full Code Here

        String defaultVS = listener.findHttpProtocol().getHttp().getDefaultVirtualServer();
        if (!defaultVS.equals(org.glassfish.api.web.Constants.ADMIN_VS)) {
            // Before we start a WebConnector, let's makes sure there is
            // not another Container already listening on that port
            DataChunk host = DataChunk.newInstance();
            char[] c = defaultVS.toCharArray();
            host.setChars(c, 0, c.length);

            DataChunk mb = DataChunk.newInstance();
            mb.setChars(new char[]{'/'}, 0, 1);

            MappingData md = new MappingData();
            try {
                mapper.map(host, mb, md);
            } catch (Exception e) {
View Full Code Here

     */
    private void removeParameterFromRequestURI(String parameter) {

        int semicolon, semicolon2;

        final DataChunk uriBC =
                coyoteRequest.getRequest().getRequestURIRef().getRequestURIBC();
       
//        start = uriBC.getStart();
//        end = uriBC.getEnd();
        semicolon = uriBC.indexOf(parameter, 0);

        if (semicolon > 0) {
            semicolon2 = uriBC.indexOf(';', semicolon + parameter.length());

            final int end;
            if (semicolon2 >= 0) {
                end = semicolon2;
                uriBC.notifyDirectUpdate();
            } else {
                end = uriBC.getLength();
            }
           
            uriBC.delete(semicolon, end);
//            uriBC.setEnd(start + semicolon);
//            byte[] buf = uriBC.getBuffer();
//            if (semicolon2 >= 0) {
//                for (int i = 0; i < end - start - semicolon2; i++) {
//                    buf[start + semicolon + i] = buf[start + i + semicolon2];
View Full Code Here

     */
    private void removeParameterFromRequestURI(String parameter) {

        int semicolon, semicolon2;

        final DataChunk uriBC =
                coyoteRequest.getRequest().getRequestURIRef().getRequestURIBC();
       
//        start = uriBC.getStart();
//        end = uriBC.getEnd();
        semicolon = uriBC.indexOf(parameter, 0);

        if (semicolon > 0) {
            semicolon2 = uriBC.indexOf(';', semicolon + parameter.length());

            final int end;
            if (semicolon2 >= 0) {
                end = semicolon2;
                uriBC.notifyDirectUpdate();
            } else {
                end = uriBC.getLength();
            }
           
            uriBC.delete(semicolon, end);
//            uriBC.setEnd(start + semicolon);
//            byte[] buf = uriBC.getBuffer();
//            if (semicolon2 >= 0) {
//                for (int i = 0; i < end - start - semicolon2; i++) {
//                    buf[start + semicolon + i] = buf[start + i + semicolon2];
View Full Code Here

        String defaultVS = listener.findHttpProtocol().getHttp().getDefaultVirtualServer();
        if (!defaultVS.equals(org.glassfish.api.web.Constants.ADMIN_VS)) {
            // Before we start a WebConnector, let's makes sure there is
            // not another Container already listening on that port
            DataChunk host = DataChunk.newInstance();
            char[] c = defaultVS.toCharArray();
            host.setChars(c, 0, c.length);

            DataChunk mb = DataChunk.newInstance();
            mb.setChars(new char[]{'/'}, 0, 1);

            MappingData md = new MappingData();
            try {
                mapper.map(host, mb, md);
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of org.glassfish.grizzly.http.util.DataChunk

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.