Package snap.web

Class HTTPResponse

java.lang.Object
snap.web.HTTPResponse

public class HTTPResponse extends Object
A class to represent an HTTP response.
  • Field Details

    • _code

      protected int _code
    • _message

      protected String _message
    • _contentType

      protected String _contentType
    • _contentLength

      protected int _contentLength
    • _lastModified

      protected long _lastModified
    • _bytes

      protected byte[] _bytes
    • _cookies

      protected List<String> _cookies
    • _time

      protected long _time
    • OK

      public static final int OK
      See Also:
    • BAD_REQUEST

      public static final int BAD_REQUEST
      See Also:
    • UNAUTHORIZED

      public static final int UNAUTHORIZED
      See Also:
    • FORBIDDEN

      public static final int FORBIDDEN
      See Also:
    • NOT_FOUND

      public static final int NOT_FOUND
      See Also:
  • Constructor Details

    • HTTPResponse

      public HTTPResponse()
  • Method Details

    • getCode

      public int getCode()
      Returns the response return code.
    • getMessage

      public String getMessage()
      Returns the response return message.
    • getHeaders

      public List<HTTPRequest.Header> getHeaders()
      Returns the headers.
    • addHeader

      public void addHeader(String aKey, String aValue)
      Adds a header for key.
    • getHeaderString

      public String getHeaderString()
      Returns the headers as a string.
    • getCookies

      public List<String> getCookies()
      Returns the cookies.
    • getCookieString

      public String getCookieString()
      Returns the cookie string.
    • getContentType

      public String getContentType()
      Returns the content type.
    • getContentLength

      public int getContentLength()
      Returns the content length.
    • getLastModified

      public long getLastModified()
      Returns the last modified time.
    • getBytes

      public byte[] getBytes()
      Returns the bytes.
    • getText

      public String getText()
      Returns the response byte string.
    • getJSON

      public JSValue getJSON()
      Returns the JSON.
    • getResponseTime

      public long getResponseTime()
      Returns the response time in milliseconds.
    • getSummary

      public String getSummary()
      Returns a response summary string.
    • toString

      public String toString()
      Standard toString implementation.
      Overrides:
      toString in class Object
    • toStringProps

      public String toStringProps()
      Returns a string representation.