Class HTTP1Util

java.lang.Object
org.omegazero.http.h1.HTTP1Util

public final class HTTP1Util extends Object
HTTP/1 utility functions.
Since:
1.2.1
  • Field Details

  • Method Details

    • toChunk

      public static byte[] toChunk(byte[] data)
      Wraps the given data in a HTTP/1 data chunk used in chunked transfer encoding.

      The resulting byte array has this format:

       
       <length of data as hexadecimal number>\r\n
       <given data>\r\n
       
       
      Parameters:
      data - The data to wrap
      Returns:
      The data as a chunk
    • parseHTTPRequest

      public static HTTPRequestData parseHTTPRequest(byte[] data, int offset, boolean secure) throws InvalidHTTPMessageException
      Parses a complete HTTP request header block using a HTTP1RequestReceiver from the given data, starting at offset.
      Parameters:
      data - The data
      offset - The index to start reading at
      secure - See HTTP1RequestReceiver(boolean)
      Returns:
      A HTTPRequestData containing the HTTP header and any trailing body data
      Throws:
      InvalidHTTPMessageException - If the given data contains an invalid or incomplete HTTP request header
    • parseHTTPResponse

      public static HTTPResponseData parseHTTPResponse(byte[] data, int offset) throws InvalidHTTPMessageException
      Parses a complete HTTP response header block using a HTTP1ResponseReceiver from the given data, starting at offset.
      Parameters:
      data - The data
      offset - The index to start reading at
      Returns:
      A HTTPResponseData containing the HTTP header and any trailing body data
      Throws:
      InvalidHTTPMessageException - If the given data contains an invalid or incomplete HTTP response header