Top Description Fields Constructors Methods
org.glassfish.grizzly.http.util

public Class HttpCodecUtils

extends Object
Class Inheritance
Imports
java.net.InetAddress, .InetSocketAddress, org.glassfish.grizzly.Buffer, .Connection, org.glassfish.grizzly.http.HttpCodecFilter, .HttpRequestPacket, org.glassfish.grizzly.memory.MemoryManager

General HttpCodec utility methods.
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
private static final int[]
pack-priv static final byte[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static Buffer
checkAndResizeIfNeeded(MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, int length)

private static int
checkCRLF(HttpCodecFilter.HeaderParsingState parsingState, byte b1, byte b2)

public static int
checkEOL(final HttpCodecFilter.HeaderParsingState parsingState, final Buffer input)

public static int
checkEOL(final HttpCodecFilter.HeaderParsingState parsingState, final byte[] input, final int end)

private static void
fastAsciiEncode(final String s, byte[] tempBuffer, final Buffer dstBuffer)

public static boolean
public static boolean
findEOL(final HttpCodecFilter.HeaderParsingState state, final byte[] input, final int end)

public static int
findSpace(final Buffer input, int offset, final int packetLimit)

public static int
findSpace(final byte[] input, int offset, final int end, final int packetLimit)

public static Buffer
getLongAsBuffer(final MemoryManager<E extends Buffer> memoryManager, final long length)

public static int
indexOf(final Buffer input, int offset, final byte b, final int packetLimit)

public static boolean

Returns:

true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE]
isNonPrintableUsAscii
(final int
the symbol code to check
ub
)

Returns true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE].

public static boolean
isNotSpaceAndTab(final byte b)

public static boolean
isSpaceOrTab(final byte b)

public static void
parseHost(final DataChunk hostDC, final DataChunk serverNameDC, final HttpRequestPacket request)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] tempBuffer, final DataChunk chunk)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] tempBuffer, final String s)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] array)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] array, final int off, final int len)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final Buffer buffer)

public static Buffer
put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte value)

public static Buffer
resizeBuffer(final MemoryManager<E extends Buffer> memoryManager, final Buffer buffer, final int grow)

public static int
skipSpaces(final Buffer input, int offset, final int packetLimit)

public static int
skipSpaces(final byte[] input, int offset, final int end, final int packetLimit)

public static byte[]

Returns:

a converted byte array, where all the char sequence's unprintable US-ASCII symbols have been replaced with spaces (' ')
toCheckedByteArray
(final CharSequence s)

Converts the a CharSequence to a byte array, eliminating all the unprintable US-ASCII symbols by replacing them with spaces (' ').

public static byte[]

Returns:

the passed dstArray
toCheckedByteArray
(final CharSequence s, final byte[]
the byte array to be used to convert the CharSequence into
dstArray
,
final int
the offset in the byte array, where the serialization will be started
arrayOffs
)

Serializes the passed CharSequence into a passed byte array starting from a given offset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DECback to summary
private static final int[] DEC
EMPTY_ARRAYback to summary
pack-priv static final byte[] EMPTY_ARRAY

Constructor Detail

HttpCodecUtilsback to summary
public HttpCodecUtils()

Method Detail

checkAndResizeIfNeededback to summary
private static Buffer checkAndResizeIfNeeded(MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, int length)
checkCRLFback to summary
private static int checkCRLF(HttpCodecFilter.HeaderParsingState parsingState, byte b1, byte b2)
checkEOLback to summary
public static int checkEOL(final HttpCodecFilter.HeaderParsingState parsingState, final Buffer input)
checkEOLback to summary
public static int checkEOL(final HttpCodecFilter.HeaderParsingState parsingState, final byte[] input, final int end)
fastAsciiEncodeback to summary
private static void fastAsciiEncode(final String s, byte[] tempBuffer, final Buffer dstBuffer)
findEOLback to summary
public static boolean findEOL(final HttpCodecFilter.HeaderParsingState state, final Buffer input)
findEOLback to summary
public static boolean findEOL(final HttpCodecFilter.HeaderParsingState state, final byte[] input, final int end)
findSpaceback to summary
public static int findSpace(final Buffer input, int offset, final int packetLimit)
findSpaceback to summary
public static int findSpace(final byte[] input, int offset, final int end, final int packetLimit)
getLongAsBufferback to summary
public static Buffer getLongAsBuffer(final MemoryManager<E extends Buffer> memoryManager, final long length)
indexOfback to summary
public static int indexOf(final Buffer input, int offset, final byte b, final int packetLimit)
isNonPrintableUsAsciiback to summary
public static boolean isNonPrintableUsAscii(final int ub)

Returns true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE].

Parameters
ub:int

the symbol code to check

Returns:boolean

true if the passed symbol code represents a non-printable US-ASCII symbol in range [Integer.MIN_VALUE; 9) U (9; 31] U [127; Integer.MAX_VALUE]

isNotSpaceAndTabback to summary
public static boolean isNotSpaceAndTab(final byte b)
isSpaceOrTabback to summary
public static boolean isSpaceOrTab(final byte b)
parseHostback to summary
public static void parseHost(final DataChunk hostDC, final DataChunk serverNameDC, final HttpRequestPacket request)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] tempBuffer, final DataChunk chunk)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] tempBuffer, final String s)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] array)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte[] array, final int off, final int len)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final Buffer buffer)
putback to summary
public static Buffer put(final MemoryManager<E extends Buffer> memoryManager, Buffer dstBuffer, final byte value)
resizeBufferback to summary
public static Buffer resizeBuffer(final MemoryManager<E extends Buffer> memoryManager, final Buffer buffer, final int grow)
Annotations
@SuppressWarnings:unchecked
skipSpacesback to summary
public static int skipSpaces(final Buffer input, int offset, final int packetLimit)
skipSpacesback to summary
public static int skipSpaces(final byte[] input, int offset, final int end, final int packetLimit)
toCheckedByteArrayback to summary
public static byte[] toCheckedByteArray(final CharSequence s)

Converts the a CharSequence to a byte array, eliminating all the unprintable US-ASCII symbols by replacing them with spaces (' ').

Parameters
s:CharSequence

CharSequence

Returns:byte[]

a converted byte array, where all the char sequence's unprintable US-ASCII symbols have been replaced with spaces (' ')

toCheckedByteArrayback to summary
public static byte[] toCheckedByteArray(final CharSequence s, final byte[] dstArray, final int arrayOffs)

Serializes the passed CharSequence into a passed byte array starting from a given offset. All the unprintable US-ASCII symbols will be replaced with spaces (' ').

Parameters
s:CharSequence

CharSequence

dstArray:byte[]

the byte array to be used to convert the CharSequence into

arrayOffs:int

the offset in the byte array, where the serialization will be started

Returns:byte[]

the passed dstArray

Exceptions
IllegalArgumentException:
if there is no enough space in the dstArray to serialize the CharSequence