Package io.varhttp

Class VarResponseStream

java.lang.Object
io.varhttp.VarResponseStream
All Implemented Interfaces:
ResponseStream

public class VarResponseStream extends Object implements ResponseStream
  • Constructor Details

  • Method Details

    • getContentWriter

      public BufferedWriter getContentWriter(String fileName, String contentType, Charset charset)
      Description copied from interface: ResponseStream
      Get writer that writes to response body in streaming way. This should trigger file download in browser.
      Specified by:
      getContentWriter in interface ResponseStream
      Parameters:
      fileName - Name of file for download eg. name.csv
      contentType - File format eg. text/csv for csv files
      charset - Character encoding of the file content eg. StandardCharsets.UTF-8 for UTF-8 encoding
      Returns:
      writer that writes to response body
    • getOutputStream

      public OutputStream getOutputStream(String contentType, Charset charset)
      Description copied from interface: ResponseStream
      Get the output-stream of the response. Used to write non-string content.
      Specified by:
      getOutputStream in interface ResponseStream
      Parameters:
      contentType - Content format eg. image/png for PNG files
      charset - Character encoding of the file content eg. StandardCharsets.UTF-8 for UTF-8 encoding
      Returns:
      the output stream of the response.
    • write

      public void write(Object object)
      Specified by:
      write in interface ResponseStream
    • write

      public void write(Object object, String forcedContentType)
      Specified by:
      write in interface ResponseStream