Class CefriumContentResponse

java.lang.Object
com.cefrium.CefriumContentResponse

public final class CefriumContentResponse extends Object
The answer of a CefriumContentServer: status, MIME type, headers and a body stream. The SDK reads the stream on a background thread and closes it.
  • Constructor Details

    • CefriumContentResponse

      public CefriumContentResponse(String mimeType, InputStream body)
      A 200 OK response.
      Parameters:
      mimeType - The MIME type, e.g. text/html; see CefriumContentServers.mimeTypeOf(String) to derive it from a path.
      body - The body, read to its end; null for none.
  • Method Details

    • ofText

      public static CefriumContentResponse ofText(String mimeType, String text)
      A 200 OK text response, UTF-8.
    • setStatus

      public CefriumContentResponse setStatus(int code, String reason)
      Sets the status code and reason phrase (default 200 OK).
    • setCharset

      public CefriumContentResponse setCharset(String charset)
      Sets the charset of a text body, e.g. utf-8.
    • setHeader

      public CefriumContentResponse setHeader(String name, String value)
      Sets a response header, replacing one of the same name. Content-Type and Content-Length come from the MIME type, charset and length.
    • setContentLength

      public CefriumContentResponse setContentLength(long length)
      Sets the body length in bytes, when known. A known length lets the page seek: Range requests are answered from it (media, large files).
    • getStatus

      public int getStatus()
    • getReason

      public String getReason()
    • getMimeType

      public String getMimeType()
    • getCharset

      public String getCharset()
    • getHeader

      public String getHeader(String name)
      A header set on this response, by name in any case, or null.
    • getHeaders

      public Map<String,String> getHeaders()
      A copy of the headers set on this response; names compare in any case.
    • getBody

      public InputStream getBody()
    • getContentLength

      public long getContentLength()
      The body length, or -1 when unknown.