Class URLResponse

java.lang.Object
nl.colorize.util.http.URLResponse
All Implemented Interfaces:
Resource

public class URLResponse extends Object implements Resource
Represents an HTTP response that is returned after sending an HTTP request to a URL. Used in conjunction with URLLoader, which supports/uses a variety of HTTP clients depending on the platform.
  • Constructor Details

    • URLResponse

      public URLResponse(int status, Headers headers, byte[] body)
    • URLResponse

      public URLResponse(int status, Headers headers, String body)
  • Method Details

    • getHeader

      public Optional<String> getHeader(String name)
      Returns the value of the HTTP header with the specified name. Using this method is equivalent to getHeaders().get(name).
    • getHeaderValues

      public List<String> getHeaderValues(String name)
      Returns all values for the HTTP header with the specified name. Using this method is equivalent to getHeaders().getAll(name).
    • getContentType

      public Optional<String> getContentType()
      Returns the value of the HTTP Content-Type header.
    • openStream

      public InputStream openStream()
      Specified by:
      openStream in interface Resource
    • openReader

      public BufferedReader openReader(Charset charset)
      Specified by:
      openReader in interface Resource
    • read

      public String read(Charset charset)
      Specified by:
      read in interface Resource
    • readBody

      public String readBody()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getStatus

      public int getStatus()
    • getHeaders

      public Headers getHeaders()
    • getBody

      public byte[] getBody()
    • getSslSession

      public SSLSession getSslSession()
    • setSslSession

      protected void setSslSession(SSLSession sslSession)