Package io.fusionauth.http.util
Class HTTPTools
java.lang.Object
io.fusionauth.http.util.HTTPTools
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA record that stores a parameterized header value. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferbuildExpectResponsePreamble(HTTPResponse response, int maxLength) Builds the HTTP response head section (status line, headers, etc).static ByteBufferbuildResponsePreamble(HTTPResponse response, int maxLength) Builds the HTTP response head section (status line, headers, etc).static booleanisDigitCharacter(byte ch) Determines if the given character (byte) is a digit (i.e.static booleanisHexadecimalCharacter(byte ch) Determines if the given character (byte) is an allowed hexadecimal character (i.e.static booleanisTokenCharacter(byte ch) Determines if the given character (byte) is an allowed HTTP token character (header field names, methods, etc).static booleanisURICharacter(byte ch) Naively determines if the given character (byte) is an allowed URI character.static booleanisValueCharacter(byte ch) static voidparseEncodedData(byte[] data, int start, int length, Map<String, List<String>> result) Parses URL encoded data either from a URL parameter list in the query string or the form body.static HTTPTools.HeaderValueparseHeaderValue(String value) Parses an HTTP header value that is a standard semicolon separated list of values.
-
Constructor Details
-
HTTPTools
public HTTPTools()
-
-
Method Details
-
buildExpectResponsePreamble
Builds the HTTP response head section (status line, headers, etc).- Parameters:
response- The response.maxLength- The maximum length of the complete HTTP response head section.- Returns:
- The bytes of the response head section.
-
buildResponsePreamble
Builds the HTTP response head section (status line, headers, etc).- Parameters:
response- The response.maxLength- The maximum length of the complete HTTP response head section.- Returns:
- The bytes of the response head section.
-
isDigitCharacter
public static boolean isDigitCharacter(byte ch) Determines if the given character (byte) is a digit (i.e. 0-9)- Parameters:
ch- The character as a byte since HTTP is ASCII.- Returns:
- True if the character is a digit.
-
isHexadecimalCharacter
public static boolean isHexadecimalCharacter(byte ch) Determines if the given character (byte) is an allowed hexadecimal character (i.e. 0-9a-zA-Z)- Parameters:
ch- The character as a byte since HTTP is ASCII.- Returns:
- True if the character is a hexadecimal character.
-
isTokenCharacter
public static boolean isTokenCharacter(byte ch) Determines if the given character (byte) is an allowed HTTP token character (header field names, methods, etc).Covered by https://www.rfc-editor.org/rfc/rfc9110.html#name-fields
- Parameters:
ch- The character as a byte since HTTP is ASCII.- Returns:
- True if the character is a token character.
-
isURICharacter
public static boolean isURICharacter(byte ch) Naively determines if the given character (byte) is an allowed URI character.- Parameters:
ch- The character as a byte since URIs are ASCII.- Returns:
- True if the character is a URI character.
-
isValueCharacter
public static boolean isValueCharacter(byte ch) -
parseEncodedData
public static void parseEncodedData(byte[] data, int start, int length, Map<String, List<String>> result) Parses URL encoded data either from a URL parameter list in the query string or the form body.- Parameters:
data- The data as a character array.start- The start index to start parsing from.length- The length to parse.result- The result Map to put the value into.
-
parseHeaderValue
Parses an HTTP header value that is a standard semicolon separated list of values.- Parameters:
value- The header value.- Returns:
- The HeaderValue record.
-