Class Web.Result

java.lang.Object
com.codename1.backend.Web.Result
Enclosing class:
Web

public static final class Web.Result extends Object
An outbound response: status, body, and libcurl's message when it failed.
  • Method Details

    • getStatus

      public int getStatus()
      The HTTP status, or -1 when the transfer itself failed.
    • isSuccess

      public boolean isSuccess()
    • getBody

      public byte[] getBody()
    • getBodyAsString

      public String getBodyAsString()
    • getError

      public String getError()
      Non-null only when the transfer failed before producing a status.
    • getHeaders

      public Map getHeaders()

      The response headers, lower-cased names to values.

      A response's headers are half of what an API says -- the ETag S3 returns for a PUT, the content type of an object, the rate-limit budget a service publishes -- and a client that can only read the body cannot see any of it. Names are lower-cased because HTTP header names are case insensitive and a caller should not have to guess which case this server chose.

    • getHeader

      public String getHeader(String name)

      The FIRST value for a name, matched case-insensitively. Null when absent.

      First rather than last, which is what this used to answer -- and the two differ only for a field the response repeated, which is the case that was losing data. Use getHeaderValues for a field that is legitimately repeated: Set-Cookie is the one every response has, and its values cannot be joined back together because an Expires attribute contains a comma of its own.

    • getHeaderValues

      public List getHeaderValues(String name)

      Every value the response carried for a name, in arrival order.

      Empty, never null, when the response had none. A repeated field used to collapse to one value here, so a response setting three cookies delivered one and nothing said the others had been dropped.