Examples of HeaderParsingState


Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

                               httpContent,
                               httpContent.isLast());
    }

    private void initTrailerParsing(HttpPacketParsing httpPacket) {
        final HeaderParsingState headerParsingState =
                httpPacket.getHeaderParsingState();
        final ContentParsingState contentParsingState =
                httpPacket.getContentParsingState();

        headerParsingState.subState = 0;
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

    private boolean parseLastChunkTrailer(final FilterChainContext ctx,
                                          final HttpHeader httpHeader,
                                          final HttpPacketParsing httpPacket,
                                          final Buffer input) {
        final HeaderParsingState headerParsingState =
                httpPacket.getHeaderParsingState();
        final ContentParsingState contentParsingState =
                httpPacket.getContentParsingState();

        final HttpCodecFilter filter = headerParsingState.codecFilter;
        final boolean result = filter.parseHeadersFromBuffer(httpHeader,
                                                   contentParsingState.trailerHeaders,
                                                   headerParsingState,
                                                   input);
        if (result) {
            if (contentParsingState.trailerHeaders.size() > 0) {
                filter.onHttpHeadersParsed(httpHeader, ctx);
            }
        } else {
            headerParsingState.checkOverflow("The chunked encoding trailer header is too large");
        }
       
        return result;
    }
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

    }

    private static boolean parseHttpChunkLength(
            final HttpPacketParsing httpPacket,
            final Buffer input) {
        final HeaderParsingState parsingState = httpPacket.getHeaderParsingState();

        while (true) {
            switch (parsingState.state) {
                case 0: {// Initialize chunk parsing
                    final int pos = input.position();
                    parsingState.start = pos;
                    parsingState.offset = pos;
                    parsingState.packetLimit = pos + MAX_HTTP_CHUNK_SIZE_LENGTH;
                }

                case 1: { // Skip heading spaces (it's not allowed by the spec, but some servers put it there)
                    final int nonSpaceIdx = skipSpaces(input,
                            parsingState.offset, parsingState.packetLimit);
                    if (nonSpaceIdx == -1) {
                        parsingState.offset = input.limit();
                        parsingState.state = 1;
                       
                        parsingState.checkOverflow("The chunked encoding length prefix is too large");
                        return false;
                    }
                   
                    parsingState.offset = nonSpaceIdx;
                    parsingState.state = 2;
                }
               
                case 2: { // Scan chunk size
                    int offset = parsingState.offset;
                    int limit = Math.min(parsingState.packetLimit, input.limit());
                    long value = parsingState.parsingNumericValue;

                    while (offset < limit) {
                        final byte b = input.get(offset);
                        if (isSpaceOrTab(b) || /*trailing spaces are not allowed by the spec, but some server put it there*/
                                b == Constants.CR || b == Constants.SEMI_COLON) {
                            parsingState.checkpoint = offset;
                        } else if (b == Constants.LF) {
                            final ContentParsingState contentParsingState =
                                    httpPacket.getContentParsingState();
                            contentParsingState.chunkContentStart = offset + 1;
                            contentParsingState.chunkLength = value;
                            contentParsingState.chunkRemainder = value;
                           
                            parsingState.state = CHUNK_LENGTH_PARSED_STATE;
                           
                            return true;
                        } else if (parsingState.checkpoint == -1) {
                            if (DEC[b & 0xFF] != -1 && checkOverflow(value)) {
                                value = (value << 4) + (DEC[b & 0xFF]);
                            } else {
                                throw new HttpBrokenContentException("Invalid byte representing a hex value within a chunk length encountered : " + b);
                            }
                        } else {
                            throw new HttpBrokenContentException("Unexpected HTTP chunk header");
                        }

                        offset++;
                    }

                    parsingState.parsingNumericValue = value;
                    parsingState.offset = offset;
                    parsingState.checkOverflow("The chunked encoding length prefix is too large");
                    return false;

                }
            }
        }
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

        return (Method.HEAD.equals(request.getMethod()));
    }

    private static Buffer parseTrailerCRLF(final HttpPacketParsing httpPacket,
            final Buffer input) {
        final HeaderParsingState parsingState = httpPacket.getHeaderParsingState();

        if (parsingState.state == CHUNK_LENGTH_PARSED_STATE) {
            while (input.hasRemaining()) {
                if (input.get() == Constants.LF) {
                    parsingState.recycle();
                    if (input.hasRemaining()) {
                        return input.slice();
                    }

                    return null;
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

                               httpContent,
                               httpContent.isLast());
    }

    private void initTrailerParsing(HttpPacketParsing httpPacket) {
        final HeaderParsingState headerParsingState =
                httpPacket.getHeaderParsingState();
        final ContentParsingState contentParsingState =
                httpPacket.getContentParsingState();

        headerParsingState.subState = 0;
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

    private boolean parseLastChunkTrailer(final FilterChainContext ctx,
                                          final HttpHeader httpHeader,
                                          final HttpPacketParsing httpPacket,
                                          final Buffer input) {
        final HeaderParsingState headerParsingState =
                httpPacket.getHeaderParsingState();
        final ContentParsingState contentParsingState =
                httpPacket.getContentParsingState();

        final HttpCodecFilter filter = headerParsingState.codecFilter;
        final boolean result = filter.parseHeadersFromBuffer(httpHeader,
                                                   contentParsingState.trailerHeaders,
                                                   headerParsingState,
                                                   input);
        if (result) {
            if (contentParsingState.trailerHeaders.size() > 0) {
                filter.onHttpHeadersParsed(httpHeader, ctx);
            }
        } else {
            headerParsingState.checkOverflow("The chunked encoding trailer header is too large");
        }
       
        return result;
    }
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

    }

    private static boolean parseHttpChunkLength(
            final HttpPacketParsing httpPacket,
            final Buffer input) {
        final HeaderParsingState parsingState = httpPacket.getHeaderParsingState();

        while (true) {
            switch (parsingState.state) {
                case 0: {// Initialize chunk parsing
                    final int pos = input.position();
                    parsingState.start = pos;
                    parsingState.offset = pos;
                    parsingState.packetLimit = pos + MAX_HTTP_CHUNK_SIZE_LENGTH;
                    parsingState.state = 1;
                }

                case 1: { // Scan chunk size
                    int offset = parsingState.offset;
                    int limit = Math.min(parsingState.packetLimit, input.limit());
                    long value = parsingState.parsingNumericValue;

                    while (offset < limit) {
                        final byte b = input.get(offset);
                        if (b == Constants.CR || b == Constants.SEMI_COLON) {
                            parsingState.checkpoint = offset;
                        } else if (b == Constants.LF) {
                            final ContentParsingState contentParsingState =
                                    httpPacket.getContentParsingState();
                            contentParsingState.chunkContentStart = offset + 1;
                            contentParsingState.chunkLength = value;
                            contentParsingState.chunkRemainder = value;
                            parsingState.state = 2;

                            return true;
                        } else if (parsingState.checkpoint == -1) {
                            if (DEC[b & 0xFF] != -1) {
                                value = value * 16 + (DEC[b & 0xFF]);
                            } else {
                                throw new HttpBrokenContentException("Invalid byte representing a hex value within a chunk length encountered : " + b);
                            }
                        } else {
                            throw new HttpBrokenContentException("Unexpected HTTP chunk header");
                        }

                        offset++;
                    }

                    parsingState.parsingNumericValue = value;
                    parsingState.offset = offset;
                    parsingState.checkOverflow("The chunked encoding length prefix is too large");
                    return false;

                }
            }
        }
View Full Code Here

Examples of org.glassfish.grizzly.http.HttpCodecFilter.HeaderParsingState

    }

    private static Buffer parseTrailerCRLF(final HttpPacketParsing httpPacket,
            final Buffer input) {
        final HeaderParsingState parsingState = httpPacket.getHeaderParsingState();

        if (parsingState.state == 2) {
            while (input.hasRemaining()) {
                if (input.get() == Constants.LF) {
                    parsingState.recycle();
                    if (input.hasRemaining()) {
                        return input.slice();
                    }

                    return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.