Class HttpResponse

java.lang.Object
com.hedera.hashgraph.sdk.HttpResponse

public final class HttpResponse extends Object
One response from an HttpTransport.

Note that this is the SDK's own transport-layer type, not java.net.http.HttpResponse.

Header names are ASCII-lowercased and values are list-valued, and both are normative. The same wire header otherwise produces a different key in every runtime — Go canonicalises to Retry-After, browsers lowercase, and the JDK preserves whatever the server sent behind a case-insensitive comparator that is lost the moment the map is copied. HTTP/2 lowercases every header name on the wire while HTTP/1.1 does not, so a helper reading Retry-After would find it against one mirror node and miss it against another. List-valued because a single-valued map silently discards all but one value of a repeated header.

  • Method Details

    • create

      public static HttpResponse create(int statusCode, byte[] body, Map<String,List<String>> headers)
      Create a response.
      Parameters:
      statusCode - the HTTP status code
      body - the response body; defensively copied
      headers - the response headers; names are lowercased and values copied
      Returns:
      the new response
    • getStatusCode

      public int getStatusCode()
      Extract the HTTP status code.
      Returns:
      the status code
    • getBody

      public byte[] getBody()
      Extract a copy of the response body.
      Returns:
      the body
    • getHeaders

      public Map<String,List<String>> getHeaders()
      Extract the response headers, with lowercased names.
      Returns:
      an unmodifiable map, never null
    • getFirstHeaderValue

      public Optional<String> getFirstHeaderValue(String name)
      Extract the first value of a header.
      Parameters:
      name - the header name, matched after lowercasing
      Returns:
      the first value, or empty when the header is absent
    • toString

      public String toString()
      Overrides:
      toString in class Object