Class HTTPTools

java.lang.Object
io.fusionauth.http.util.HTTPTools

public final class HTTPTools extends Object
  • Constructor Details

    • HTTPTools

      public HTTPTools()
  • Method Details

    • buildExpectResponsePreamble

      public static ByteBuffer buildExpectResponsePreamble(HTTPResponse response, int maxLength)
      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

      public static ByteBuffer buildResponsePreamble(HTTPResponse response, int maxLength)
      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

      public static HTTPTools.HeaderValue parseHeaderValue(String value)
      Parses an HTTP header value that is a standard semicolon separated list of values.
      Parameters:
      value - The header value.
      Returns:
      The HeaderValue record.