java.lang.Object
com.smeup.kokos.sdk.entrypoint.restapi.handler.httpAdapters.HttpResponse

public final class HttpResponse extends Object
Immutable HTTP response model. Represents the complete HTTP response to be sent back to the client.
  • Constructor Details

    • HttpResponse

      public HttpResponse(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback)
  • Method Details

    • status

      public void status(int status)
    • headers

      public void headers(List<Map<String,String>> headers)
    • header

      public void header(String name, String value)
    • writeChunk

      public void writeChunk(byte... bytes)
      Writes a partial (non-last) chunk to the response. Does not signal completion to Jetty — call closeStream() or send(int) when done.
    • send

      public void send(int status, byte[] body)
    • send

      public void send(int status)
    • closeStream

      public void closeStream()
    • setCookie

      public void setCookie(HttpCookie cookie)
    • sendFile

      public void sendFile(Path file, boolean download) throws IOException
      Sends a file as the response body with appropriate Content-Type and Content-Disposition headers.
      Parameters:
      file - the file to send
      download - if true, sets Content-Disposition to "attachment" (browser download); if false, sets it to "inline" (browser display)
      Throws:
      IOException
    • sendFile

      public void sendFile(Path file, String fileName, boolean download) throws IOException
      Sends a file as the response body with a custom filename.
      Parameters:
      file - the file to send
      fileName - the filename to use in the Content-Disposition header
      download - if true, sets Content-Disposition to "attachment" (browser download); if false, sets it to "inline" (browser display)
      Throws:
      IOException
    • redirect

      public void redirect(String redirectUri)