Class HttpResponse

java.lang.Object
com.petarmc.lib.net.HttpResponse

public final class HttpResponse extends Object
Represents an HTTP response with status code, body, and headers.
  • Field Details

    • statusCode

      public final int statusCode
      The HTTP status code of the response.
    • body

      public final String body
      The body of the response as a string.
    • headers

      public final Map<String,List<String>> headers
      The HTTP headers of the response.
  • Constructor Details

    • HttpResponse

      public HttpResponse(int statusCode, String body, Map<String,List<String>> headers)
      Constructs a new HttpResponse.
      Parameters:
      statusCode - the HTTP status code
      body - the response body, or empty string if null
      headers - the response headers, or empty if null
  • Method Details

    • isSuccess

      public boolean isSuccess()
      Returns true if the status code indicates a successful response (200-299).
      Returns:
      true if status code is 200–299, false otherwise
    • toString

      public String toString()
      Returns a string representation of the HttpResponse, including status code and body length.
      Overrides:
      toString in class Object
      Returns:
      string summary of the response