Class HttpResponse
java.lang.Object
com.smeup.kokos.sdk.entrypoint.restapi.handler.httpAdapters.HttpResponse
Immutable HTTP response model.
Represents the complete HTTP response to be sent back to the client.
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResponse(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback) -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidvoidvoidsend(int status) voidsend(int status, byte[] body) voidSends a file as the response body with appropriate Content-Type and Content-Disposition headers.voidSends a file as the response body with a custom filename.voidsetCookie(HttpCookie cookie) voidstatus(int status) voidwriteChunk(byte... bytes) Writes a partial (non-last) chunk to the response.
-
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
-
header
-
writeChunk
public void writeChunk(byte... bytes) Writes a partial (non-last) chunk to the response. Does not signal completion to Jetty — callcloseStream()orsend(int)when done. -
send
public void send(int status, byte[] body) -
send
public void send(int status) -
closeStream
public void closeStream() -
setCookie
-
sendFile
Sends a file as the response body with appropriate Content-Type and Content-Disposition headers.- Parameters:
file- the file to senddownload- if true, sets Content-Disposition to "attachment" (browser download); if false, sets it to "inline" (browser display)- Throws:
IOException
-
sendFile
Sends a file as the response body with a custom filename.- Parameters:
file- the file to sendfileName- the filename to use in the Content-Disposition headerdownload- if true, sets Content-Disposition to "attachment" (browser download); if false, sets it to "inline" (browser display)- Throws:
IOException
-
redirect
-